2013-02-19 62 views
0

我试图通过SOAP调用Web服务。我觉得PHP请求看起来是正确的。以下是SOAP PHP代码和XML。请让我知道可能是错的。我在技术上不断得到对象的回应没有财产。SOAP PHP问题“编码:对象没有'模式'属性”

这是错误消息:

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'schema' property

$client = new SoapClient(
    'Link.asmx?wsdl', 
    array(
     'soap_version' => SOAP_1_1, 
     'trace'  => 1, 
    ) 
); 

$result = $client->OTA_VehAvailRate(
    array(
     'OTA_VehAvailRateRQ' => array(
      'VehAvailRQCore' => array(
       'VehRentalCore' => array(
        'type'   => 'VehicleRentalCoreType', 
        'PickUpLocation' => array(
         'LocationCode' => 'ERLAX01', 
        ), 
        'PickUpDateTime' => '2013-03-14T12:00:00', 
        'ReturnDateTime' => '2013-03-16T12:00:00', 
        'ReturnLocation' => array(
         'LocationCode' => 'ERLAX01', 
        ), 
       ), 
       'VendorPrefs' => array(
        'VendorPref' => array(
         'Code'  => '*****', 
         'CodeContext' => '******', 
        ), 
       ), 
       'VehPrefs'  => array(
        'VehPref' => array(
         'Code' => 'HFG', 
        ), 
       ), 

       'RateQualifier' => array(
        'PromotionCode' => '', 
        'RateQualifier' => '', 
       ), 
      ), 
     ) 
    ) 
); 

print_r($result); 

下面是XML模式。

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Body> 
     <tns:OTA_VehAvailRate xmlns:tns="http://www.opentravel.org/OTA/2003/05" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:tnsC="http://www.w3.org/1999/xhtml" xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense" xmlns:tnsB="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
      <AA:OTA_VehAvailRateRQ xmlns:AA="http://www.opentravel.org/OTA/2003/05" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" Version="0"> 
       <AA:VehAvailRQCore> 
        <AA:VehRentalCore xs:type="AA:VehicleRentalCoreType" PickUpDateTime="2013-03-14T12:00:00" ReturnDateTime="2013-03-16T12:00:00"> 
         <AA:PickUpLocation LocationCode="ERLAX01" /> 
         <AA:ReturnLocation LocationCode="ERLAX01" /> 
        </AA:VehRentalCore> 
        <AA:VendorPrefs> 
         <AA:VendorPref Code="****" CodeContext="******" /> 
        </AA:VendorPrefs> 
        <AA:VehPrefs> 
         <AA:VehPref Code="HEG" /> 
        </AA:VehPrefs> 
        <AA:RateQualifier PromotionCode="" RateQualifier="" /> 
       </AA:VehAvailRQCore> 
      </AA:OTA_VehAvailRateRQ> 
     </tns:OTA_VehAvailRate> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

请让我知道我做错了什么。非常感谢

POST /OTA2011A/OTASrvc.asmx HTTP/1.1 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://www.opentravel.org/OTA/2003/05/OTA_VehAvailRate" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <OTA_VehAvailRate xmlns="http://www.opentravel.org/OTA/2003/05"> 
     <OTA_VehAvailRateRQ> 
     <xsd:schema>schema</xsd:schema>xml</OTA_VehAvailRateRQ> 
    </OTA_VehAvailRate> 
    </soap:Body> 
</soap:Envelope> 
+0

您可能会错过规范中的某些内容,也许您需要传递模式属性或类似内容。 – silkfire 2013-02-19 16:59:54

+0

也共享架构。 – SparKot 2013-02-19 19:15:24

+0

此错误通常是由错误顺序传递元素引起的。 – EmmyS 2013-02-19 19:43:12

回答

0

如果您在OTA的工作,我真的建议你尝试https://github.com/goetas-webservices/soap-client

是完全PHP SOAP客户端,不依赖于ext-soap从PHP。 它已经支持PSR7,multiclient,并允许通过IDE为类型提示生成类。

https://github.com/goetas-webservices/soap-client-demo是演示项目,允许您了解如何使用客户端来使用通用SOAP Web服务。

该项目基于内部使用OTA作为测试套件(并且测试套件已通过)的https://github.com/goetas-webservices/xsd2php

相关问题