Webservice I'm calling returns SoapFault with xml embedded in <detail>
element - this is how it looks in SoapUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>some error msg</faultstring>
<detail>
<e:exchange-error xmlns:e="http://mycompany.com/faults">
<e:message-data id="00001" type="005"/>
<e:result-data date="2017-02-13 15:44:33" code="1401" ref="2457798154426512"/>
</e:exchange-error>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>`
It seems like PHP implementation does not pass the attributes of xml nodes, it just returns the values (which in this case, are empty):
try {
$resp = $this->_soap->__soapCall("myMethod", ['param-data' => $req->get()]);
var_dump($response);
} catch (\SoapFault $e) {
if (empty($e->detail->{'exchange-error'}->{'result-data'})) {
echo "it's empty :(
";
var_dump($e->detail->{'exchange-error'});
}
}
$ php -f foobar.php
it's empty :(
object(stdClass)#7 (4) {
["message-data"]=>
string(0) ""
["result-data"]=>
string(0) ""
}
Is there a way to get exchange-error
object with attribute values? Or maybe just get XML/string from detail
and parse it? Fault message is defined in WSDL, so I guess its structure should be known on the client side.
The namespace attributes are not returned in the php response. They are only used to define wich type of response object it is.
If you want to ease your day, use a WSDL to php generator such as the PackageGenerator project. It will ease you constructing the request, it will ease you receiving the response, finally it will ease you the handling of any error.