Consider this example SOAP Client script:
$SOAP = new SoapClient($WDSL); // Create a SOAP Client from a WSDL // Build an array of data to send in the request. $Data = array('Something'=>'Some String','SomeNumber'=>22); $Response = $SOAP->DoRemoteFunction($Data); // Send the request.
On the last line, PHP takes the arguments from the array you specified, and, using the WSDL, builds the XML request to send, then sends it.
How can I get PHP to show me the actual XML it's built?
I'm troubleshooting an application and need to see the actual XML of the request.
To send XML content in the body of a request, use the $value$ notation to show that a parameter should be inserted. and the values input1 and input2 as inputs to the Connector Function, a request is made with the values of input1 and input2 substituted into the Request Body.
SOAP messages are transported by HTTP protocol. To view the HTTP request, click RAW at SoapUI Request window (left side). The Request is posted to the web-server. Hence, the POST method of Http is used.
SOAP is the Simple Object Access Protocol, a messaging standard defined by the World Wide Web Consortium and its member editors. SOAP uses an XML data format to declare its request and response messages, relying on XML Schema and other technologies to enforce the structure of its payloads.
A SOAP message is encoded as an XML document, consisting of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element, contained in <Body> , is used for reporting errors.
Use getLastRequest
. It returns the XML sent in the last SOAP request.
echo "REQUEST:\n" . $SOAP->__getLastRequest() . "\n";
And remember, this method works only if the SoapClient object was created with the trace
option set to TRUE
. Therefore, when creating the object, use this code:
$SOAP = new SoapClient($WDSL, array('trace' => 1));
$SOAP = new SoapClient($WSDL, array('trace' => true)); $Response = $SOAP->DoRemoteFunction($Data); echo "REQUEST:\n" . htmlentities($SOAP->__getLastRequest()) . "\n";
This will not only print the last request but also make the XML tags visible in the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With