[英]Consume OpenTravel WSDL with php soap
how can I handle this code and consume OTA WSDL? 如何处理此代码并使用OTA WSDL? The schema definition is http://schemas.liquid-technologies.com/OpenTravel/2008B/?page=http___www_opentravel_org_ota_2003_05.html 模式定义为http://schemas.liquid-technologies.com/OpenTravel/2008B/?page=http___www_opentravel_org_ota_2003_05.html
I tried this: 我尝试了这个:
$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);
and get this xml, where item, key and value are wrong. 并获取此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>
Thanks! 谢谢!
First edit: 首先编辑:
Nope, maybe my wsdl definition is not correct. 不,也许我的wsdl定义不正确。 I tried also with this: 我也尝试过这个:
$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]);
but this is the response 但这是回应
Cannot find dispatch method for {}OTA_VehAvailRateRQ
I'm guessing (too hard for me to test) that it misbehaves because, according the the schema, RequestorID
has neither an attribute nor a child element named ID
. 我猜测(太难测试了)它的行为不当,因为根据该架构, RequestorID
既没有属性,也没有名为ID
的子元素。 Try this ... 尝试这个 ...
$data = [
'OTA_VehAvailRateRQ'=>[
'POS'=>[
'Source'=>[
'RequestorID'=>[
'_'=>'myID',
'MessagePassword'=>'myPASSWORD'
]
]
],
...
_
must be the first element in the array. _
必须是数组中的第一个元素。 I think this should give: 我认为这应该给:
<RequestorID MessagePassword="myPASSWORD">myID</RequestorID>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.