0

I am trying to trace rare, intermittent problem. A SOAP call is made, nice XML comes back, and information is stored in a database. On rare occasions though, some information goes missing. I cannot replicate this problem, but luckily the raw XML response is logged.

I have some nice debugging tracing functions on my development environment, so I would like to go through the process, but have the SoapClient use my xml, instead of what it receives from the server. I started to just replace $result = $this->_mySoap->FUNC_NAME($params); with $result = // parse test.xml

The problem is that the native SOAP function return an instance of SimpleClass, while parsing test.xml returns an instance of SimpleXMLElement class. I could try to convert one to the other, that would defeat my original goal of tracing the source of the intermittent bug in existing code.

Any thoughts on how I can force SoapClient to use this xml from a file, instead of actually making an api call?

the Hampster
  • 876
  • 1
  • 14
  • 21
  • SimpleClass? Do you mean [`stdClass`](http://php.net/reserved.classes)? And if you want to inject your XML, I think this is possible similar to when you use curl instead of standard HTTP wrappers from PHP: http://www.php.net/manual/de/soapclient.soapclient.php#97029; [SOAP request in PHP with CURL](http://stackoverflow.com/q/7120586/367456) – hakre Aug 29 '13 at 18:57
  • Somehow I thought he wants the opposite - to simulate the XML that comes in response. – raina77ow Aug 29 '13 at 19:08
  • Currently, the only way I can think to do this, is to set up a fake server, change the URL for the request, and have it send back the XML I want to test. Replacing native SOAP with custom curl functions is simply not an option, as it defeats the whole point of debugging a single thing. – the Hampster Sep 09 '13 at 17:12

0 Answers0