Matt Brunmeier
Matt Brunmeier

Reputation:

PHP SoapClient times out

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?

Upvotes: 2

Views: 11937

Answers (5)

ahmad
ahmad

Reputation: 41

Make sure these extensions are enabled in your php.ini

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

Upvotes: 4

Amarjit
Amarjit

Reputation: 311

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.

Upvotes: 1

Matt Brunmeier
Matt Brunmeier

Reputation:

I solved this problem by saving the dynamically generated nusoap WSDL as a standalone file and all seems to be working just fine. I have no idea why this would be the case.

I'm planning to move it to PHP5 anyway, I was just using nuSoap to generate the WSDL.

Upvotes: 0

Matt Brunmeier
Matt Brunmeier

Reputation: 1310

OP again here.

A little more context: I'm hosting the service (obviously) on installittoday.com. I'm also trying to run a client from the same place just for testing purposes. I can connect to the service from literally every other site I've tried perfectly fine, and I've successfully opened a few WSDLs with the Client hosted on installittoday. It seems the site can't connect to itself for some reason.

I sincerely doubt it's a congested line issue.

Now that I've gotten this far I realize this problem probably extends beyond SOAP to some kind of Apache configuration issue, unless there's a port thing that I'm missing. I haven't set up any ports differently, is there one I should make sure I have open for SOAP?

Upvotes: 0

lsl
lsl

Reputation: 4419

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?

Upvotes: 2

Related Questions