【问题标题】:Error Calling Webservice Method Using SOAP使用 SOAP 调用 Web 服务方法时出错
【发布时间】:2015-04-20 20:27:04
【问题描述】:

谈到 SOAP,我是个菜鸟。我正在尝试发出 SOAP 请求。它一直有效,直到我使用特定方法,然后失败并显示以下消息:SOAP-ERROR: Encoding: object has not 'transactionIdIn' property

这是我的代码:

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 webservice 有一个 dequeue2 方法,它接受两个参数,subscriberId 和 transactionIdIn。显然,我错过了一些东西。任何帮助将不胜感激。

【问题讨论】:

    标签: php soap soap-client php-5.3


    【解决方案1】:

    您的脚本中有错字:

    $result = $client->dequeue2(array('subscriberId'=> "1", 'transactionId' => "0"));
    

    应该是:

    $result = $client->dequeue2(array('subscriberId'=> "1", 'transactionIdIn' => "0"));
    

    正如肥皂错误告诉你的那样。试试看,让我知道它现在是否适合你 :-)

    【讨论】:

    • 是的,这行得通。我来这里是为了结束这个问题,因为我只是注意到了自己。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 1970-01-01
    相关资源
    最近更新 更多