Get SOAP XML before __soapCall?

Can I get the XML generated by the SOAP client before sending it to the webservice?

I need this because the answer from webservice, if one of the parameters is really wrong, I get errors, for example

Server was unable to read request. 
---> There is an error in XML document (2, 408). 
---> Input string was not in a correct format.

This usually involves running tcpmon or another tcp watcher utility, grabbing a webservice call, copying and pasting xml into a text editor, and going to column 408 to find out what the problem is.

I would really like to simplify this process by sending XML to .

+5
source share
1 answer

, ( ) . SoapClient . :

-, SOAPClient , :

$client = new SoapClient($wsdl, array('trace' => true));

, SOAP . , , , :

echo("<pre>"); //to format it legibly on your screen
var_dump($client->__getLastRequestHeaders()); //the headers of your last request
var_dump($client->__getLastRequest()); //your last request

, , :

var_dump($client->__getLastResponseHeaders()); //response headers
var_dump($client->__getLastResponse()); //the response
+11

All Articles