简体   繁体   中英

PHP SOAP-Client with multiple namespace

i have a problem with my php soapclient project. Since now i used curl to send soap requests, but for different reasons i have to use the integrated soap client of PHP.

My (working) request which i used for CURL looked like this:

<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
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

Hope someone could help me Thank you!

One bug might be that you aren't setting includePreviousEventsInfo => true

A fiddler trace would show any other differences, like needing to do something to place that and mainAscReferenceId inside an "info" node. With some HTTPS sites Fiddler will offer to install a fake cert for man in the middle decoding of traffic.

You could also send the request to any other site that accepts HTTP just to see what is sent.

I sent the request to my own server and inspected the package with 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. 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...

As it seems from your wireshark xml response soapClient is not sending exact XML request which you mentioned in your problem. You can also check last generated XML with below line and debug it.

$res = $client->__getLastRequest();

Your SOAP server needs an multiple nested XML request, which you can generate by passing multi dimensional array.

$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.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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