Tracing SOAP request and response

suggest change

Sometimes we want to look at what is sent and received in the SOAP request. The following methods will return the XML in the request and response:

SoapClient::__getLastRequest()
SoapClient::__getLastRequestHeaders()
SoapClient::__getLastResponse()
SoapClient::__getLastResponseHeaders()

For example, suppose we have an ENVIRONMENT constant and when this constant’s value is set to DEVELOPMENT we want to echo all information when the call to getAddress throws an error. One solution could be:

try {
    $address = $soap_client->getAddress(1234);
} catch (SoapFault $e) {
    if (ENVIRONMENT === 'DEVELOPMENT') {
        var_dump(
            $soap_client->__getLastRequestHeaders()
            $soap_client->__getLastRequest(),
            $soap_client->__getLastResponseHeaders(),
            $soap_client->__getLastResponse()
        );
    }
    ...
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents