SOAP请求不返回正确的数据

时间:2012-10-12 22:12:42

标签: php soap wsdl

我正在尝试使用以下肥皂信封消费Innovata肥皂网

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:cus="http://CustomDataTimeTableToolKit.com/">
   <soap:Header>
      <cus:WSAuthenticate>
         <cus:CustomerRefCode>XYZ</cus:CustomerRefCode>
         <cus:Password>XXXXXXXX</cus:Password>
         <cus:WebServicesRefCode>xxx</cus:WebServicesRefCode>
      </cus:WSAuthenticate>
   </soap:Header>
   <soap:Body>
      <cus:GetSchedules>
         <cus:_sSchedulesSearchXML>&lt;GetSchedules_Input customerCode="XXX" productCode="external" dptCode="EDI" dptCodeType="STA" arvCode="LHR" arvCodeType="STA" flightDaysRange="3" MM="10" DD="11" YYYY="2012" searchType="B" cnxType="B" IncludeSummary="false" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="GetSchedules_Input.xsd"/&gt;</cus:_sSchedulesSearchXML>
      </cus:GetSchedules>
   </soap:Body>
</soap:Envelope>

我编写了以下PHP代码,它似乎有效,但没有返回正确的数据!

<?php


    $customerCode = 'XXX';
    $password = 'XXXX';

    $dptCode = 'EDI';
    $dptCodeType='STA';
    $arvCode='LHR'; 
    $arvCodeType='STA';


    $client = new SoapClient('http://ctk.innovataw3svc.com/ctk.asmx?WSDL', array('trace'=>1));
    $client->__setSoapHeaders(array(
        new SoapHeader('http://CustomDataTimeTableToolKit.com/', 
            'WSAuthenticate', 
            array(
                'CustomerRefCode' => $customerCode,
                'Password' => $password,
                'WebServicesRefCode' => 'TKC'
            )
        )
    ));
    $date = new DateTime();
    $in = new stdClass();
    $in->_sSchedulesSearchXML = sprintf(
        '<GetSchedules_Input customerCode="%s" productCode="external" dptCode="%s" dptCodeType="%s" arvCode="%s" arvCodeType="%s" flightDaysRange="3" MM="%s" DD="%s" YYYY="%s" searchType="B" cnxType="B" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="GetSchedules_Input.xsd" />',
        $customerCode, 
        $dptCode, 
        $dptCodeType, 
        $arvCode, 
        $arvCodeType, 
        $date->format('m'), 
        $date->format('d'),
        $date->format('Y')
    );


    try{
        $result = $client->GetSchedules($in);
        print_r($result);
    }
    catch(SoapFault $e){
        echo "Soap Fault: ".$e->getMessage();
    }

输出如下:

stdClass Object ( [GetSchedulesResult] => S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 320 0 S S S S S S S S S S S S S S S S S 319 0 M M M M M M M M M M M M M M M M M ER4 0 S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 M M M M M M M M M M M M M M M M M ER4 0 M M M M M S S S S S S S S S S S S 319 0 S S S S S S S S S S S S S S S S S 319 0 M M M M M S S S S S S S S S S S S 319 0 M M M M M M M M M M M M M M M M M ER4 0 M M M M M S S S S S S S S S S S S 319 0 )

我真的不知道问题出在哪里,非常感谢任何帮助。

由于

1 个答案:

答案 0 :(得分:1)

因此,看起来您正在将调试输出到网页,并且在浏览器尝试呈现页面时XML被剥离。您看到的输出是膳食代码,停止等。

换句话说,你总是得到你期望的回应。

如果是这种情况,请不要使用__getLastResponse(),而只是将$ result作为对象处理,并根据需要进行解析。