Handling SOAP Fault - Recovering fault string

Help
2008-07-24
2013-06-06
  • Vikas Roonwal
    Vikas Roonwal
    2008-07-24

    Hi,

    I started using NuSOAP and PHP quite recently

    It works great when parsing both rpc/encoded and doc/lit service WSDLs and the clients are easy to use too.
    What I have not been able to do is to extract the Fault String from a SOAP Fault.

    The error message extracted from $client->getError() is

    "XML error parsing SOAP payload on line 1: Attribute redefined"

    This is the SOAP Response

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
      <soap:Fault>
       <faultcode>soap:Server</faultcode>
       <faultstring>There is a fault string</faultstring>
       <detail>
        <FaultDetail xmlns="http://mynamespace.com">
         <Message xmlns="http://mynamespace.com">There is a permission issues</Message>
         <Cause xmlns="http://mynamespace.com">The root cause is here</Cause>
        </FaultDetail>
       </detail>
      </soap:Fault>
    </soap:Body>
    </soap:Envelope>

    How can I extract the faultstring that is present in the <soap:Fault> ??

    Thanks for any help and response,
    ~ Vikas