0

I'm having trouble viewing the xml created by the PHP SOAP client. I want to do this because I am trouble shooting a problem where I can only retrieve data from a remote service. When I try to submit an array of my object that includes updates I get a SOAP Fault:

"ObjectSave Failed. Error: Object reference not set to an instance of an object. "

Here is how I retrieve an object using the SOAP client:

$client->ObjectGet( array('ObjectID' => 1) );//this works just fine

And here is how I am trying to update using the SOAP client:

$client->ObjectSave($objectarray);//this is when I get the SOAP Fault

To see the XML I enabled tracing on the soap client like so:

$client = new SoapClient("http://beta.mywsdlvendor.com", array(
                    "trace" => true,
                    "exceptions" => false
                )
            );

I then tried to see the xml generated from the client like this:

echo $client->__getLastRequest();

Instead of XML I get this:

2013-06-04T14:16:40.744616Z76DJvRi+ktH6JtcQghzkJR2OoyALI=0-1

According to How do I see the actual XML generated by PHP SOAP Client Class? __getLastRequest() should show the xml.

Why can't I see the XML?

Community
  • 1
  • 1
user988117
  • 13
  • 8
  • I read this http://www.php.net/manual/en/soapclient.getlastrequest.php and someone commented about adding htmlentities() to see the xml so I replaced echo $client->__getLastRequest(); with echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n"; which worked wonderfully! – user988117 Jun 05 '13 at 18:43
  • Yes, by default your browser tries to read the output you send to it as HTML which tries to read the XML tags as HTML tags and drops all tags it does not know in HTML. That is HTML, tags not known are not displayed. The alternative is to tell your browser to display that as text, you can configure that in your browser, or in your webserver or by sending the `Content-Type: text/plain;` HTTP response header. Or as you did, to turn the XML into HTML first by using `htmlspecialchars()` and friends. You can now delete your question, we have that already documented on the website if you like. – hakre Jun 06 '13 at 15:34

0 Answers0