Raffael
Raffael

Reputation: 20045

Very weird SoapClient problem

 try
  {
    $client = new \SoapClient($wsdlUrl, array(
      'cache_wsdl' => 0, 'exceptions' => true, 'trace' => true));

    $client->getPage($parameter);
  }
  catch(\Exception $e)
  {
    die("exception");
  }

Okay this is what executes the SOAP request. $wsdlUrl holds the WSDLs URL and $parameter keeps an XML document.

And everything works like a charm!

Now I just add few more nodes to the XML document in $parameter and I get a fatal error.

This is not so weird necessarily, but what is weired is the combination of following three observations:

1) exceptions is set to true .... but no Exception is thrown / this was b/c I forgot to place a backslash before Exception in the catch statement.

2) instead an error is logged:

PHP Fatal error:  SoapClient::SoapClient(): 
'uri' option is required in nonWSDL mode in /var/w[...]

3) but the WSDL url is provided and of course valid, as all works again just fine after skipping the adding of the new nodes. they don't affect the wsdl parameter.

Upvotes: 1

Views: 5140

Answers (1)

Raffael
Raffael

Reputation: 20045

Okay, I tracked down the source of the problem. There is no satisfying answer really to that question but few things to learn! :)

The important thing is that the request has been sent and processed by the SOAP server. But the server responds with an error.

So, obviously, even though a fatal error regarding no wsdl and no connection parameter is triggered doesn't mean no request has been sent - which is very counter logical in my opinion b/c if no wsdl is provided and no connection params as well, then how could the request be executed?

EDIT

There is another bug in the code. I forgot to place a backslash before Exception! Without it's not referring to the Exception class.

Then an exception is thrown and caught.

Upvotes: 1

Related Questions