简体   繁体   English

具有多个命名空间的PHP SOAP-Client

[英]PHP SOAP-Client with multiple namespace

i have a problem with my php soapclient project. 我的php soapclient项目有问题。 Since now i used curl to send soap requests, but for different reasons i have to use the integrated soap client of PHP. 从现在开始我使用curl发送soap请求,但出于不同的原因,我必须使用PHP的集成soap客户端。

My (working) request which i used for CURL looked like this: 我用于CURL的我(工作)请求看起来像这样:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:asc="http://asc.ws.ideal.com" xmlns:xsd="http://getserviceeventstatus.info.asc.ws.ideal.com/xsd">
   <soap:Header/>
   <soap:Body>
      <asc:getServiceEventStatus>        
         <asc:param>       
            <xsd:info>               
               <xsd:includePreviousEventsInfo>true</xsd:includePreviousEventsInfo>               
               <xsd:mainAscReferenceId>16111294</xsd:mainAscReferenceId>        
            </xsd:info>           
          <xsd:password>xxx</xsd:password>            
          <xsd:userId>xxx</xsd:userId>
         </asc:param>
      </asc:getServiceEventStatus>
   </soap:Body>
</soap:Envelope>

My actual php script looks like that... 我的实际php脚本看起来像......

     <?php
error_reporting(E_ALL);

$wsdl = '/services/AscServiceSync?wsdl';
$location = '/services/AscServiceSync.AscServiceSyncHttpSoap11Endpoint/';

$options = array(
'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
'style'=>SOAP_RPC,
'use'=>SOAP_ENCODED,
'soap_version'=>SOAP_1_1,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout'=>15,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=>true,
"location"=>$location
);

$client = new SoapClient($wsdl, $options);
$result = $client->getServiceEventStatus(array('userId' => 'xxx', 'password' => 'xxx', 'mainAscReferenceId' => '16111294'));
var_dump ($result);
print '<br />';
print $result->success;
print '<br />';

?> 

The server returns the error message that the "param" or "info" data is missing 服务器返回错误消息“param”或​​“info”数据丢失

Hope someone could help me Thank you! 希望有人能帮帮我谢谢!

One bug might be that you aren't setting includePreviousEventsInfo => true 一个错误可能是你没有设置includePreviousEventsInfo => true

A fiddler trace would show any other differences, like needing to do something to place that and mainAscReferenceId inside an "info" node. fiddler跟踪将显示任何其他差异,例如需要执行某些操作以及将mainAscReferenceId置于“info”节点内。 With some HTTPS sites Fiddler will offer to install a fake cert for man in the middle decoding of traffic. 对于一些HTTPS站点,Fiddler将提供在流量的中间解码中为人安装假证书。

You could also send the request to any other site that accepts HTTP just to see what is sent. 您还可以将请求发送到任何其他接受HTTP的站点,以查看发送的内容。

I sent the request to my own server and inspected the package with wireshark. 我将请求发送到我自己的服务器并使用wireshark检查了包。

Thats whats sent to the server: 那是什么发送到服务器:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://asc.ws.ideal.com"><SOAP-ENV:Body><ns1:getServiceEventStatus/></SOAP-ENV:Body></SOAP-ENV:Envelope>

I also added the "includePreviousEventsInfo" value but it doesnt help at all. 我还添加了“includePreviousEventsInfo”值,但它根本没有帮助。 I found out that the server error message changes to "info" missing when i put "param" instead of "userId" - and when i change userId to "info" the error message changes to "param" missing... 当我输入“param”而不是“userId”时,我发现服务器错误消息更改为“info”缺失 - 当我将userId更改为“info”时,错误消息更改为“param”丢失...

As it seems from your wireshark xml response soapClient is not sending exact XML request which you mentioned in your problem. 从您的wireshark xml响应来看,soapClient没有发送您在问题中提到的确切XML请求。 You can also check last generated XML with below line and debug it. 您还可以使用下面的行检查上次生成的XML并进行调试。

$res = $client->__getLastRequest();

Your SOAP server needs an multiple nested XML request, which you can generate by passing multi dimensional array. 您的SOAP服务器需要多个嵌套的XML请求,您可以通过传递多维数组来生成该请求。

$reqArr = [
    'info' => [
        'includePreviousEventsInfo' => true,
        'mainAscReferenceId' => 16111294
    ],
    'password' => 'xxxxxx',
    'userId' => 'xxxxxx',
];

$res = $client->__soapCall('getServiceEventStatus', $reqArr);

If it still gives you error then check the last request XML from above method. 如果它仍然给你错误,那么从上面的方法检查最后一个请求XML。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM