Reputation: 3727
The variable $response in the below code is NULL even though it should be the value of the SOAP request. (a list of tides). When I call $client->__getLastResponse() I get the correct output from the SOAP service.
Anybody know what is wrong here? Thanks! :)
Here is my code :
$options = array(
"trace" => true,
"encoding" => "utf-8"
);
$client = new SoapClient("http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl", $options);
$params = array(
"stationId" => 8454000,
"beginDate" => "20060921 00:00",
"endDate" => "20060922 23:59",
"datum" => "MLLW",
"unit" => 0,
"timeZone" => 0
);
try {
$result = $client->getHLPredAndMetadata($params);
echo $client->__getLastResponse();
}
catch (Exception $e) {
$error_xml = $client->__getLastRequest();
echo $error_xml;
echo "\n\n".$e->getMessage();
}
var_dump($result);
Upvotes: 7
Views: 15329
Reputation: 1
I had this same issue. If I used curl against the WSDL address I got a response. Yet when the WSDL was accessed through the PHP code, an error triggered. The issue was ultimately in the CA certificate. There was an "openssl.cafile" setting, with the php.init file, that pointed to a particular certificate that the WSDL endpoint rejected.
When I commented this out - by sticking a ';' in from of the openssl.cafile setting in the /etc/php.ini file, and bounced Apache, the WSDL connection through the PHP code worked.
Since curl worked and no option to override the certificates (i.e., no -k option was used) and it worked, then you know that the server-level setting was valid for that WSDL endpoint.
Hoping this makes sense and that is of some help for someone out there.
Upvotes: 0
Reputation: 38147
The reason that the $result
(or the response to the SoapCall) is null
is indeed because the WSDL is invalid.
I just ran into the same problem - the WSDL said the response should be PackageChangeBatchResponse
yet the actual XML returns has PackageChangeResponse
Changing the WSDL to match the response / changing the response to match the WSDL resolves the issue
Upvotes: 5
Reputation: 4142
you should give an option parameter as below :
<?php
// below $option=array('trace',1);
// correct one is below
$option=array('trace'=>1);
$client=new SoapClient('some.wsdl',$option);
try{
$client->aMethodAtRemote();
}catch(SoapFault $fault){
// <xmp> tag displays xml output in html
echo 'Request : <br/><xmp>',
$client->__getLastRequest(),
'</xmp><br/><br/> Error Message : <br/>',
$fault->getMessage();
}
?>
"trace" parameter enables the output of request. Now, you should see the SOAP request. (source: PHP.net
Upvotes: 2