how can I handle this code and consume OTA WSDL? The schema definition is 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 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. 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
. 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>
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.