Silly SoapClient

Sam made some changes to a SOAP service one customer has – and suddenly our automated tests kept failing. “WTF?” we thought.

We persistently got the same error (e.g. Fatal error: SOAP-ERROR: Encoding: object hasn’t ‘SortResults’ property in ….) yet the generated WSDL file (when viewed through a web browser etc) no longer has SortResults in it.

We checked :

  • Proxy settings,
  • Apache configuration (and restarted Apache)
  • svn reverted files
  • DNS and more.

Then it turned out the SoapClient PHP object caches the WSDL file by default in e.g. /tmp/wsdl-blahblahblah. (Where blahblahblah looks very much like an md5). And it doesn’t make much of an effort to check it’s validity. Obviously the documentation does state this, but it does seem like the wrong default behaviour to me.

Solution: Add something to the automated tests to delete /tmp/wsdl-*. OR pass into the SoapClient constructor an array of options like :

$client = new SoapClient('http://somewhere/blah.php?wsdl", array(cache_wsdl => WSDL_CACHE_NONE)

Time wasted: Too much.


Posted

in

,

by

Comments

3 responses to “Silly SoapClient”

  1. Dan Field Avatar
    Dan Field

    It’s an ini_file setting, so I’d have thought you would have been aware of it.

  2. David Goodwin Avatar

    Dan – yes, so I now see…. it’s easy to say in retrospect perhaps… 🙂

  3. John Avatar
    John

    Thank you thank you thank you thank you thank you thank you thank you. This just saved me hours of effort trying to debug a SOAP service.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *