使用 SOAP 调用 Webservice 方法时出错
Error Calling Webservice Method Using SOAP
说到 SOAP,我是个菜鸟。我正在尝试发出 SOAP 请求。它一直有效,直到我找到一个特定的方法,然后失败并显示以下消息:SOAP-ERROR: Encoding: object hasn't 'transactionIdIn' 属性
这是我的代码:
error_reporting(-1);
ini_set("soap.wsdl_cache_enabled", "0");
//Set up client; username and password replaced for security
try {
$client = new SoapClient('https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs/wsdl/OTSWebSvcs.wsdl',
array('Username'=> {username},
'Password' => {password}));
}
catch (Exception $e) {
echo $e->getMessage();
}
//Call dequeue2 method
try {
$result = $client->dequeue2(array('subscriberId'=> "1", 'transactionId' => "0"));
}
catch (Exception $e) {
echo $e->getMessage();
}
这是我正在调用的 wsdl:https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs/wsdl/OTSWebSvcs.wsdl
以下是我正在查看的 wsdl 的相关部分:
xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://websvcs.otswebws">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://websvcs.otswebws">
<import namespace="http://datatype.otswebws"/>
<element name="dequeueResponse">...</element>
<element name="getSubscriberInfo">...</element>
<element name="getSubscriberInfoResponse">...</element>
<element name="dequeue2">
<complexType>
<sequence>
<element name="subscriberId" type="xsd:int"/>
<element name="transactionIdIn" type="xsd:long"/>
</sequence>
</complexType>
</element>
<wsdl:portType name="OTSWebSvcs">
<wsdl:operation name="dequeue">...</wsdl:operation>
<wsdl:operation name="getSubscriberInfo">...</wsdl:operation>
<wsdl:operation name="dequeue2">
<wsdl:input message="impl:dequeue2Request" name="dequeue2Request"></wsdl:input>
<wsdl:output message="impl:dequeue2Response" name="dequeue2Response"></wsdl:output>
<wsdl:fault message="impl:WSException" name="WSException"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
所以,我想我不了解网络服务的设置方式。据我了解,这个 OTSWebSvcs web 服务有一个 dequeue2 方法,它接受两个参数,subscriberId 和 transactionIdIn。显然,我错过了一些东西。任何帮助将不胜感激。
您的脚本中有错字:
$result = $client->dequeue2(array('subscriberId'=> "1", 'transactionId' => "0"));
应该是:
$result = $client->dequeue2(array('subscriberId'=> "1", 'transactionIdIn' => "0"));
正如 soap Error 告诉您的那样。尝试一下,让我知道它现在是否适合你:-)
说到 SOAP,我是个菜鸟。我正在尝试发出 SOAP 请求。它一直有效,直到我找到一个特定的方法,然后失败并显示以下消息:SOAP-ERROR: Encoding: object hasn't 'transactionIdIn' 属性
这是我的代码:
error_reporting(-1);
ini_set("soap.wsdl_cache_enabled", "0");
//Set up client; username and password replaced for security
try {
$client = new SoapClient('https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs/wsdl/OTSWebSvcs.wsdl',
array('Username'=> {username},
'Password' => {password}));
}
catch (Exception $e) {
echo $e->getMessage();
}
//Call dequeue2 method
try {
$result = $client->dequeue2(array('subscriberId'=> "1", 'transactionId' => "0"));
}
catch (Exception $e) {
echo $e->getMessage();
}
这是我正在调用的 wsdl:https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs/wsdl/OTSWebSvcs.wsdl
以下是我正在查看的 wsdl 的相关部分:
xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://websvcs.otswebws">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://websvcs.otswebws">
<import namespace="http://datatype.otswebws"/>
<element name="dequeueResponse">...</element>
<element name="getSubscriberInfo">...</element>
<element name="getSubscriberInfoResponse">...</element>
<element name="dequeue2">
<complexType>
<sequence>
<element name="subscriberId" type="xsd:int"/>
<element name="transactionIdIn" type="xsd:long"/>
</sequence>
</complexType>
</element>
<wsdl:portType name="OTSWebSvcs">
<wsdl:operation name="dequeue">...</wsdl:operation>
<wsdl:operation name="getSubscriberInfo">...</wsdl:operation>
<wsdl:operation name="dequeue2">
<wsdl:input message="impl:dequeue2Request" name="dequeue2Request"></wsdl:input>
<wsdl:output message="impl:dequeue2Response" name="dequeue2Response"></wsdl:output>
<wsdl:fault message="impl:WSException" name="WSException"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
所以,我想我不了解网络服务的设置方式。据我了解,这个 OTSWebSvcs web 服务有一个 dequeue2 方法,它接受两个参数,subscriberId 和 transactionIdIn。显然,我错过了一些东西。任何帮助将不胜感激。
您的脚本中有错字:
$result = $client->dequeue2(array('subscriberId'=> "1", 'transactionId' => "0"));
应该是:
$result = $client->dequeue2(array('subscriberId'=> "1", 'transactionIdIn' => "0"));
正如 soap Error 告诉您的那样。尝试一下,让我知道它现在是否适合你:-)