1

With PHP, when trying to call some method with SOAP, I always bust the maximum execution time. However, since calling this method worked in the past, when I remove 'cache_wsdl' => WSDL_CACHE_NONE it starts working.

If I fetch the WSDL with a file_get_contents I get it completely. However, it just doesn't work when I call the method

$client = new SoapClient("https://.../file.asmx?wsdl", array(
    'soap_version' => SOAP_1_1,
    'trace' => true,
    'cache_wsdl' => WSDL_CACHE_NONE
));

$result = $client->SomeMethod($parameters);

At some point I was able to get the error:

Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in myfile.php
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://abc.def...', 'http://someser....', 1, 0)
#1 myfile.php(27): SoapClient->__call('SomeMethod', Array)
#2 myfile.php(27): SoapClient->SomeMethod(Object(Z)) #3 {main} thrown in myfile.php on line 27

I would love to get more diagnostics errors but I do not know how?
I pay for this WSDL service and it is unusable... Is it this WSDL server's fault? How can I be sure and what can I say to this service provider? The call to SomeMethod doesn't answer in time? (even though I am able to download the WSDL)

4

1 回答 1

1

So, you said that when you disable wsdl_cache then the service starts working.

I had a lot of frustration moments because of having wsdl_cache turned "on" on my development environments. The thing is that if you have wsdl_cache turned on on your development environment, then the SoapClient object will download the wsdl file just the first time you call the service. Then lets suppose you change the return type or the name of an existing function, some times, the SoapClient object will not download the new wsdl with the new modifications and then the generated xml soap request will no longer match the web service description anymore, and the call will fail.

This happen to me using Zend Framework and the class Zend_Soap_Client and generating the wsdl dynamically based on the annotations of the class that i setup to handle the service requests using Zend_Soap_Autodiscover.

In linux, php stores the cached wsdl files in side the /tmp folder with a filname prefix "wsdl". You can go there and delete all those files, then the next request will grab the new wsdl. Or better enough, just turn off the wsdl cache settings in your php.ini file or just putting this line on the very beginning of the script where you make the call.

ini_set('soap.wsdl_cache_enabled',0);

PS: Turning off wsdl_cache is recommended on development environments because of all the modifications made to the web service source code. Having wsdl_cache off can dramatically slow down the performance on high traffic production environments. So i only recommend it off on development.

于 2013-05-17T19:27:33.243 回答