PHP SoapClient times out

11,519

Solution 1

Make sure these extensions are enabled in your php.ini

extension=php_curl.dll 
extension=php_openssl.dll 
extension=php_soap.dll

Solution 2

Also loading from here fine.

Try connecting to it from the site you want the client on with a web browser, or if its a remote machine with no proxy set up use curl:

curl http://www.installittoday.com/api/server.php?wsdl

That will tell you if you can even get a connection to that site via the machine.

You could also try multiple connects, or increasing default_socket_timeout if your machines connection speed is limited/congested.

What ports are you trying to connect over?

Solution 3

For anyone coming across this error. Try disabling the WSDL cache, either from your php.ini or a parameter in your SOAP call.

The problem is, PHP by default caches the WSDL file in the temp folder. After the file is first cached, PHP keeps on using this file. It is only refreshed after 24 hours (the default ttl for the cache).

So if you change your WSDL file, PHP will pickup the old one, resulting in an error like the OP. Matt, your problem was solved by using referencing a file that is never cached.

The reason it is cached by default because your server has to request the file and then parse it, which takes a bit of fetching and processing.

You have two options, either amend the relevant variable in your php.ini or send a param along with your SOAP call.

For example:

$client = new SoapClient($webservice, array('classmap' => $soap_class_map, 'cache_wsdl' => WSDL_CACHE_NONE));

Hope this helps.

Share:
11,519

Related videos on Youtube

Admin
Author by

Admin

Updated on April 19, 2022

Comments

  • Admin
    Admin about 2 years

    I'm trying to call a Soap Client for testing purposes from the same server that I'm running the service on. My WSDL is at: http://www.installittoday.com/api/server.php?wsdl I'm trying to load it simply with:

    
        $client = new SoapClient('http://www.installittoday.com/api/server.php?wsdl');
    

    but I get back the error:

    
    Warning: SoapClient::SoapClient(http://www.installittoday.com/api/server.php?wsdl) [soapclient.soapclient]: failed to open stream: Connection timed out in /home/installi/public_html/api/client.php on line 4  
    
    Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://www.installittoday.com/api/server.php?wsdl" in /home/installi/public_html/api/client.php on line 4  
    
    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.installittoday.com/api/server.php?wsdl' : failed to load external entity "http://www.installittoday.com/api/server.php?wsdl" in /home/installi/public_html/api/client.php:4 Stack trace: #0 /home/installi/public_html/api/client.php(4): SoapClient->SoapClient('http://www.inst...') #1 {main} thrown in /home/installi/public_html/api/client.php on line 4
    
    

    Yet I can set up the client just fine from another site of mine. Is this a firewall issue or what?

  • Dave
    Dave over 12 years
    This was the problem I had ultimately. The machine I was requesting the wsdl happened to be the one serving it. There was a dns config issue that prevented it from resolving its domain name.