问题描述
下面代码中的变量 $response 是 NULL,即使它应该是 SOAP 请求的值.(潮汐表).当我调用 $client->__getLastResponse() 时,我从 SOAP 服务中获得了正确的输出.
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! :)
这是我的代码:
$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);
推荐答案
$result
(或对 SoapCall 的响应)为 null
的原因确实是因为WSDL 无效.
The reason that the $result
(or the response to the SoapCall) is null
is indeed because the WSDL is invalid.
我刚刚遇到了同样的问题 - WSDL 说响应应该是 PackageChangeBatchResponse
但实际的 XML 返回有 PackageChangeResponse
I just ran into the same problem - the WSDL said the response should be PackageChangeBatchResponse
yet the actual XML returns has PackageChangeResponse
更改 WSDL 以匹配响应/更改响应以匹配 WSDL 可解决问题
Changing the WSDL to match the response / changing the response to match the WSDL resolves the issue
这篇关于SoapClient 返回“NULL",但 __getLastResponse() 返回 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!