PHP SOAP请求发送多个元素

时间:2016-10-22 18:57:58

标签: php xml web-services soap wsdl

我正在尝试使用PHP Soap客户端订阅Web服务。我的PHP代码确实成功访问了Web服务,但没有传递所有需要的元素来订阅。我尝试了两个不同的PHP文档,结果相同。我的代码基于以下链接perfection kills。我使用SoapUi来解析wsdl,而subscribe函数的格式为

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ass="http://assignment.soap.assignshare" xmlns:xsd="http://request.assignment.soap.assignshare/xsd">
   <soapenv:Header/>
   <soapenv:Body>
      <ass:Subscribe>
         <ass:SasReqSubscribe>
            <xsd:Source>VendorC</xsd:Source>
            <xsd:Dest>http://192.168.50.3:26001/SAIWebService</xsd:Dest>
            <xsd:MsgTag>1</xsd:MsgTag>
            <xsd:SupportsPendingAssignments>false</xsd:SupportsPendingAssignments>
            <xsd:AppVersion>AppVersion</xsd:AppVersion>
            <xsd:ProtocolVersion>1.20</xsd:ProtocolVersion>
            <xsd:SubscriptionPort>http://localhost:26001/SAIWebService</xsd:SubscriptionPort>
         </ass:SasReqSubscribe>
      </ass:Subscribe>
   </soapenv:Body>
</soapenv:Envelope>

我正在尝试使用PHP Soap创建sae结果。我的第一个PHP代码如下。  

    $wsdl = "http://192.168.50.3:26001/SAIWebservice?singlewsdl";

    $client = new SoapClient($wsdl, array(
                            "trace"=>1,
                            "exceptions"=>0));

    $name7 = "http://xx.xxx.183.202:8080";*/

    $parameters= array("Source"=>'Test',"Dest"=>'http://192.168.50.3:26001/SAIWebService',"MsgTag"=>1,"SupportsPendingAssignments"=>0,
    "AppVersion"=>'AppVersion,"ProtocolVersion"=>1.20,"SubscriptionPort"=>"http://xx.xxx.183.202:8080');

    $values = $client->Subscribe($parameters);

    print "<pre>\n";

    print "<br />\n Request : ".htmlspecialchars($client->__getLastRequest());

    print "<br />\n Response: ".htmlspecialchars($client->__getLastResponse());

    print "</pre>";

我使用Wireshark捕获发布的XML,但元素为“Source”,“Dest”,“MsgTag”,“SupportsPendingAssignments”,“ProtocolVersion”&amp; “SubscriptionPort”未发布。“ https://devzone.zend.com/2202/php-and-soap-first-steps/

第二个PHP,结果相同  

    $wsdl = "http://192.168.50.3:26001/SAIWebservice?singlewsdl";

    $client = new SoapClient($wsdl, array(
                            "trace"=>1,
                            "exceptions"=>0));
    $name1 = "Test";
    $name2 = "http://192.168.50.3:26001/SAIWebService";
    $name3 = "1";
    $name4 = "false";
    $name5 = "AppVersion";
    $name6 = "1.20";
    $name7 = "http://xx.xxx.183.202:8080";

    $parameters= array("Source"=>$name1,"Dest"=>$name2,"MsgTag"=>$name3,"SupportsPendingAssignments"=>$name4,"AppVersion"=>$name5,"ProtocolVersion"=>$name6,"SubscriptionPort"=>$name7);

    $values = $client->Subscribe($parameters);

    print "<pre>\n";

    print "<br />\n Request : ".htmlspecialchars($client->__getLastRequest());

    print "<br />\n Response: ".htmlspecialchars($client->__getLastResponse());

    print "</pre>";

?>   

我很感激为什么在PHP Soap客户端请求中没有传递元素的任何帮助。

1 个答案:

答案 0 :(得分:0)

我习惯通过soap调用作为stdclass PHP对象发送参数。不是数组。也许只是使用参数将数组转换为(object)$parameters调用

$client->subscribe的对象