我在这里发现了这个问题: PHP Soap Issue: Server was unable to process request. ---> Object reference not set to an instance of an object
我有类似的问题,只有WSDL是私有的,所以我想我会尝试使用基本的时区SOAP客户端。
另一个问题的解决方案不可能与私有WSDL一起使用。
$response = $client->getTimeZoneTime(array('timezone'=>'ZULU'));
我真正需要的是一种获取多维PHP数组并将其放入SOAP格式的XML文档中的方法,不会让它变得疯狂并产生类似的东西,例如: -
<key>GetTimeZoneTime</key>
<item>ZULU</item>
这是我的PHP:
try {
$WSDL = 'http://www.nanonull.com/TimeService/TimeService.asmx?WSDL';
$client = new SoapClient($WSDL,
array(
"trace" => 1,
"exceptions" => 1,
"soap_version" => SOAP_1_1
));
$xml = '<GetTimeZoneTime><timezone>ZULU</timezone></GetTimeZoneTime>';
$xmlvar = new SoapVar(
$xml,
XSD_ANYXML
);
$response = $client->getTimeZoneTime($xmlvar);
echo "<pre>\n";
echo "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
echo "</pre>";
} catch (SoapFault $exception) {
echo "<pre>\n";
echo "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
echo "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
echo $exception;
echo "</pre>";
}
这是它产生的请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.Nanonull.com/TimeService/">
<SOAP-ENV:Body>
<GetTimeZoneTime>
<timezone>ZULU</timezone>
</GetTimeZoneTime>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP Fault是:
Server was unable to process request. ---> Object reference not set to an instance of an object.
将多维PHP数组转换为适当的SOAP请求格式的正确方法是什么?
返回的SOAP错误究竟意味着什么?
编辑:在其他地方搜索之后,我想我会尝试创建一个PHP类来镜像服务器上的变量。这也不起作用。
class TimeZone {
public function __construct ()
{
$this->timezone = 'ZULU';
}
}
$WSDL = 'http://www.nanonull.com/TimeService/TimeService.asmx?WSDL';
$client = new SoapClient($WSDL,
array(
"trace" => 1,
"exceptions" => 1,
"soap_version" => SOAP_1_1
));
$xmlvar = new SoapVar(new TimeZone(), SOAP_ENC_OBJECT, "TimeZone");
$response = $client->getTimeZoneTime($xmlvar);
答案 0 :(得分:1)
对于Timezone,添加classmap参数使其工作:
$client = new SoapClient($WSDL,
array(
"trace" => 1,
"exceptions" => 1,
"soap_version" => SOAP_1_1,
"classmap" => array('timezone' => 'TimeZone')
));
$obj = new TimeZone();
$response = $client->getTimeZoneTime($obj);
echo "<h1>".$response->getTimeZoneTimeResult."</h1>";
对于我遇到的主要问题,它需要一个新问题。
我可能错了,但我收集错误信息的含义是双重的: