I am quite complicated doing a requirement to a webservice with PHP Soap. The requests in which I consult data work well, but there is one that makes a reservation in a hotel and throws me the error
SOAP-ERROR: Encoding: object has no 'any' property
The following code asks ws to bring the hotels dates a city, it works perfectly. In the documentation the different xml are shown.
$xml = '<Request Version="1.0" encoding="utf-8">
<d>2</d>
<a>AF-AVV</a>
<l>esp</l>
</Request>';
$funcion = "GetHotels";
ini_set('soap.wsdl_cache_enabled', 0);
$wsdl = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc?Wsdl';
$client = new SoapClient($wsdl);
$xml_busqueda = simplexml_load_string($xml, NULL, LIBXML_NOCDATA);
try {
$respuesta = $client->__soapCall($funcion, array('Parameters' => $xml_busqueda));
echo "RESPUESTA DEL WEB SERVICE";
echo "<pre>";
print_r($respuesta);
echo "<pre>";
} catch (SoapFault $exception) {
echo $exception->getMessage();
}
In the process that makes "Book" (book), it gives me the error SOAP-ERROR: Encoding: object has no 'any' property. The xml of the reservation is the one that appears in the documentation. It is quite long, but it basically contains the necessary data to make a reservation.
$xml = '<Request Type="Reservation" Version="1.0">
<affiliateid>AF-AVV</affiliateid>
<language>esp</language>
<currency>PE</currency>
<uid>m2r32b14es10socxtxs4y4ht</uid>
<ip>201.147.113.232</ip>
<firstname>prueba</firstname>
<lastname>prueba</lastname>
<emailaddress>[email protected]</emailaddress>
<country>MX</country>
<address>bonampak 4</address>
<city>cancun</city>
<state>QROO</state>
<zip>77500</zip>
<total>12346.51</total>
<naturalperson>
<gender></gender>
<nationality></nationality>
<number></number>
<type></type>
</naturalperson>
<legalperson>
<businessname></businessname>
<number></number>
<type></type>
</legalperson>
<phones>
<phone>
<type>2</type>
<number>9981454221</number>
</phone>
</phones>
<hotels>
<hotel>
<hotelid>100</hotelid>
<roomtype>SUPOV</roomtype>
<mealplan>EP</mealplan>
<datearrival>20141113</datearrival>
<datedeparture>20141115</datedeparture>
<couponid></couponid>
<marketid>INTER</marketid>
<contractid>2</contractid>
<dutypercent>0</dutypercent>
<rooms>
<room>
<amount>985.34</amount>
<status>AV</status>
<ratekey>90cba867-f916-4fb9-8cb4-ec925ded0fb3</ratekey>
<adults>1</adults>
<kids>1</kids>
<k1a>5</k1a>
</room>
</rooms>
</hotel>
</hotels>
<flights>
<flight>
<quoteid>1885e28d-5198-4dd5-92e6-6cee14a66b1b</quoteid>
<ratekey>bc1b40db-b0fb-40ff-92b3-6b7cde0d8685</ratekey>
<passengers>
<passenger>
<isadult>Y</isadult>
<agechild></agechild>
<firstname>Prueba</firstname>
<lastname>Prueba</lastname>
<daybirthday>05</daybirthday>
<monthbirthday>06</monthbirthday>
<yearbirthday>1905</yearbirthday>
<numberfrecuent></numberfrecuent>
<idfrecuent></idfrecuent>
<naturalperson>
<type></type>
<number></number>
</naturalperson>
</passenger>
</passengers>
<contacts>
<contact>
<firstname>Prueba</firstname>
<lastname>Prueba</lastname>
<email></email>
<phones>
<phone>
<type>1</type>
<number>(+52)654654646</number>
</phone>
</phones>
</contact>
</contacts>
</flight>
</flights>
<shuttles>
<shuttle>
<shuttleid>599</shuttleid>
<shuttletype>R</shuttletype>
<adults>2</adults>
<kids>0</kids>
<airportarrival>Aeropuerto Internacional de Cancun </airportarrival>
<airlinearrival>AC</airlinearrival>
<datearrival>20140501</datearrival>
<hourarrival>18:00</hourarrival>
<flightarrival>123</flightarrival>
<airlinedeparture>PU</airlinedeparture>
<datedeparture>20140502</datedeparture>
<hourdeparture>04:00</hourdeparture>
<flightdeparture>456</flightdeparture>
<hotelid>640</hotelid>
<amount>724.8</amount>
</shuttle>
</shuttles>
<insurances>
<insurance>
<insuranceid>12</insuranceid>
<adults>2</adults>
<children>0</children>
<amount>105.1049</amount>
<ratekey>4f2b132f-6663-427a-aa75-61c5d8e37635</ratekey>
</insurance>
</insurances>
<cars>
<car>
<agency>2</agency>
<sipp>AR133</sipp>
<amount>869.76</amount>
<brancharrival>139</brancharrival>
<airportarrival>CUN</airportarrival>
<datearrival>20140501</datearrival>
<hourarrival>12:00</hourarrival>
<branchdeparture>139</branchdeparture>
<airportdeparture>CUN</airportdeparture>
<datedeparture>20140502</datedeparture>
<hourdeparture>12:00</hourdeparture>
</car>
</cars>
<tours>
<tour>
<tourid>413</tourid>
<serviceid>1</serviceid>
<cityid>NOCIUDAD</cityid>
<adults>2</adults>
<kids>0</kids>
<datetour>20140711</datetour>
<hotelname>Cancun Clipper Club, Cancun Zona Hotelera Punta Cancun, Mexico</hotelname>
<timetour>00:00</timetour>
<amount>2035.62</amount>
<dutypercent>0</dutypercent>
</tour>
</tours>
<payments>
<cardpayment>
<type>86</type>
<bank>BC3</bank>
<number>XXXXXXXXXXXXXX</number>
<securitycode>1212</securitycode>
<expirationmonth>03</expirationmonth>
<expirationyear>2018</expirationyear>
<holdername>prueba prueba</holdername>
<address>bonampak 4</address>
<city>cancun</city>
<state>QROO</state>
<country>MX</country>
<zip>77500</zip>
<amount>12346.51</amount>
</cardpayment>
</payments>
</Request>';
$funcion = "Book";
ini_set('soap.wsdl_cache_enabled', 0);
$wsdl = 'http://testxml.e-tsw.com/AffiliateService/AffiliateService.svc?Wsdl';
$client = new SoapClient($wsdl);
$xml_reserva = simplexml_load_string($xml, NULL, LIBXML_NOCDATA);
try {
$respuesta = $client->__soapCall($funcion, array('Parameters' => $xml_reserva));
} catch (SoapFault $exception) {
echo $exception->getMessage();
}
As you may notice, the code is the same. Just change the xml and the "GetHotels" function to "Book". Next the document wsdl
I appreciate your help to get out of this trap that has me testing for several days. Maybe I'm focusing badly on this whole thing, because I'm not an expert on Soap.
Greetings and thanks, Luis