如何处理此代码并使用OTA WSDL?架构定义为http://schemas.liquid-technologies.com/OpenTravel/2008B/?page=http___www_opentravel_org_ota_2003_05.html
我试过了:
$client = new \SoapClient('myservice?wsdl', array(
'trace'=>true
));
$data = [
'OTA_VehAvailRateRQ'=>[
'POS'=>[
'Source'=>[
'RequestorID'=>[
'ID'=>'myID',
'MessagePassword'=>'myPASSWORD'
]
]
],
'VehAvailRQCore'=>[
'VehRentalCore'=>[
'PickUpDateTime'=>'2018-05-25T08:30:00+00:00',
'ReturnDateTime'=>'2018-05-26T08:30:00+00:00',
'PickUpLocation'=>[
'LocationCode'=>'CODE',
],
'ReturnLocation'=>[
'LocationCode'=>'CODE',
]
]
]
]
];
$result = $client->__soapCall('OTA_VehAvailRate', $data);
并获取此xml,其中item,key和value是错误的。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<SOAP-ENV:Body>
<ns1:OTA_VehAvailRateRQ>
<ns1:POS>
<ns1:Source>
<item>
<key>RequestorID</key>
<value>
<item>
<key>ID</key>
<value>bookingservice</value>
</item>
<item>
<key>MessagePassword</key>
<value>123booking</value>
</item>
</value>
</item>
</ns1:Source>
</ns1:POS>
<ns1:VehAvailRQCore>
<ns1:VehRentalCore PickUpDateTime="2018-05-25T08:30:00+00:00" ReturnDateTime="2018-05-26T08:30:00+00:00">
<ns1:PickUpLocation/>
<ns1:ReturnLocation/>
</ns1:VehRentalCore>
</ns1:VehAvailRQCore>
</ns1:OTA_VehAvailRateRQ>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
谢谢!
首先编辑:
不,也许我的wsdl定义不正确。我也试过这个:
$data = '<OTA_VehAvailRateRQ>
<POS>
<Source>
<RequestorID ID="myID" MessagePassword="myPASSWORD">
<CompanyName>WEB001</CompanyName>
</RequestorID>
</Source>
</POS>
<VehAvailRQCore>
<VehRentalCore PickUpDateTime="2018-05-25T08:30:00+00:00" ReturnDateTime="2018-05-26T08:30:00+00:00">
<PickUpLocation LocationCode="APR" />
<ReturnLocation LocationCode="APR" />
</VehRentalCore>
</VehAvailRQCore>
</OTA_VehAvailRateRQ>';
$soapBody = new \SoapVar($data, \XSD_ANYXML, null, 'http://www.opentravel.org/OTA/2003/05');
$result = $client->__soapCall('OTA_VehAvailRate', [$soapBody]);
但这是回复
Cannot find dispatch method for {}OTA_VehAvailRateRQ
答案 0 :(得分:0)
我猜测(对我来说太难测试)它行为不端,因为根据模式,RequestorID
既没有属性也没有名为ID
的子元素。试试这个......
$data = [
'OTA_VehAvailRateRQ'=>[
'POS'=>[
'Source'=>[
'RequestorID'=>[
'_'=>'myID',
'MessagePassword'=>'myPASSWORD'
]
]
],
...
_
必须是数组中的第一个元素。我认为这应该给出:
<RequestorID MessagePassword="myPASSWORD">myID</RequestorID>