发送多个元素的PHP SOAP请求


PHP SOAP Request to send multiple elements

我正在尝试使用PHP Soap客户端订阅web服务。我的PHP代码成功到达了web服务,但没有传递订阅所需的所有元素。我尝试了两个不同的PHP文档,结果相同。我的代码是基于以下链接https://devzone.zend.com/2202/php-and-soap-first-steps/。我使用SoapUi来解析wsdl,订阅函数的格式为

<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创建相同的结果。我的第一个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"&"SubscriptionPort"未发布。WireShark Capture

第二个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客户端请求中传递。

我习惯通过soap调用作为stdclass PHP对象发送参数。不是数组。也许只是在$client->subscribe调用

中将带有参数的数组转换为带有(object)$parameters的对象