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.
……………………………………….
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 some kind of “bullshit” …
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.
……………………………………….
I assume that you work with non-WSDL mode, because of error “…is required in nonWSDL mode”. Instead of die(“exception”); you can print exception print_r($e); and then die();
echo ‘
';
print_r($e); // show exception
echo '
‘;
die();From PHP SoapClient documentation: If working in non-WSDL mode, the location and uri options must be set, where location is the URL to request and uri is the target namespace of the SOAP service.