CURL Post xml data to soap service return wsdl XML in php -
i trying response using curl request. soap service running fine soap-client. using curl not getting proper response.
here code sample:
$bookingrq = '<?xml version="1.0" encoding="utf-8"?> <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:header> <interface xmlns="http://api.hotels-vacation.com/documentation/xml/ota/4/2011b/" channelidentifierid="his_vacation_xml4h" version="2011b" interface="vacation quick connect xml 4 ota"> <componentinfo user="xmlhisjp" pwd="5kh86rsr" componenttype="hotel" /> </interface> </soap-env:header> <soap-env:body requestid="201505101528000000001" transaction="ota_hotelresrq"> <ota_hotelresrq xmlns="http://www.opentravel.org/ota/2003/05" timestamp="2012-05-03t15:47:24-04:00" echotoken="2012-05-03t15:47:24-04:00" target="production" version="1.000" primarylangid="en"> <hotelreservations> <hotelreservation roomstayreservation="true" createdatetime="2012-05-03t15:47:24-04:00"> <uniqueid type="14" id="hz10014035" /> <roomstays> <roomstay> <roomtypes> <roomtype roomtypecode="rr" /> </roomtypes> <rateplans> <rateplan rateplancode="rpln"> <mealsincluded mealplancodes="bre" /> </rateplan> </rateplans> <roomrates> <roomrate numberofunits="1" effectivedate="2012-05-13" expiredate="2012-05-16" roomtypecode="rr" rateplancode="rpln"> <rates> <rate effectivedate="2012-05-13" expiredate="2012-05-14" ratetimeunit="day"> <base amountbeforetax="10000" amountaftertax="10980" decimalplaces="2" currencycode="usd" /> <total amountbeforetax="10000" amountaftertax="10980" decimalplaces="2" currencycode="usd" /> </rate> <rate effectivedate="2012-05-14" expiredate="2012-05-16" ratetimeunit="day"> <base amountbeforetax="12000" amountaftertax="13050" decimalplaces="2" currencycode="usd" /> <total amountbeforetax="24000" amountaftertax="26100" decimalplaces="2" currencycode="usd" /> </rate> </rates> </roomrate> </roomrates> <guestcounts> <guestcount agequalifyingcode="10" count="1" /> <guestcount agequalifyingcode="8" count="1" /> </guestcounts> <timespan start="2012-05-13" end="2012-05-16" /> <depositpayments> <requiredpayment> <acceptedpayments> <acceptedpayment rph="1"> <paymentcard cardtype="1" cardcode="visa" cardnumber="4321432143214327" expiredate="1007" /> </acceptedpayment> </acceptedpayments> <amountpercent amount="130.80" /> <deadline absolutedeadline="2012-12-15" /> </requiredpayment> </depositpayments> <basicpropertyinfo hotelcode="105487" /> <resguestrphs> <resguestrph rph="1" /> <resguestrph rph="2" /> </resguestrphs> <specialrequests> <specialrequest language="en" requestcode="114"> <text language="en">honeymoon</text> </specialrequest> <specialrequest language="en" requestcode="21"> <text language="en">non-smoking</text> </specialrequest> </specialrequests> </roomstay> </roomstays> <resguests> <resguest resguestrph="1" agequalifyingcode="10" age="21"> <profiles> <profileinfo> <profile profiletype="1"> <customer> <personname> <givenname>john</givenname> <surname>dow</surname> </personname> </customer> </profile> </profileinfo> </profiles> </resguest> <resguest resguestrph="2" agequalifyingcode="8" age="10"> <profiles> <profileinfo> <profile profiletype="1"> <customer> <personname> <givenname>neil</givenname> <surname>dow</surname> </personname> </customer> </profile> </profileinfo> </profiles> </resguest> </resguests> </hotelreservation> </hotelreservations> </ota_hotelresrq> </soap-env:body> </soap-env:envelope>'; $headers = array( "cache-control: no-cache", "content-type: text/xml; charset=\"utf-8\"", "accept: text/xml", "soapaction: \"ota_hotelresrq\"", "pragma: no-cache", "content-length: ".strlen($bookingrq) ); $url = 'http://chetu.volateam.com/chetu/push/soapserver/pullservice.php?wsdl'; $ch = curl_init(); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_timeout, 60); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $bookingrq); $result = curl_exec($ch); $xmlstring = str_replace('soap-env:', '', $result); $xml = simplexml_load_string($xmlstring); $json = json_encode($xml); $array = json_decode($json,true);
i getting wsdl xml code response. google did not find solution. getting response below mentioned array.
array ( [@attributes] => array ( [name] => pullservicehis [targetnamespace] => http://chetu.volateam.com/chetu/push/soapserver/pullservice.php )
[types] => array ( ) [porttype] => array ( [@attributes] => array ( [name] => pullservicehisport ) [operation] => array ( [@attributes] => array ( [name] => ota_hotelresrq ) [documentation] => method takes xml request , return string response [input] => array ( [@attributes] => array ( [message] => tns:ota_hotelresrqin ) ) [output] => array ( [@attributes] => array ( [message] => tns:ota_hotelresrqout ) ) ) ) [binding] => array ( [@attributes] => array ( [name] => pullservicehisbinding [type] => tns:pullservicehisport ) [operation] => array ( [@attributes] => array ( [name] => ota_hotelresrq ) [input] => array ( ) [output] => array ( ) ) ) [service] => array ( [@attributes] => array ( [name] => pullservicehisservice ) [port] => array ( [@attributes] => array ( [name] => pullservicehisport [binding] => tns:pullservicehisbinding ) ) ) [message] => array ( [0] => array ( [@attributes] => array ( [name] => ota_hotelresrqin ) [0] => array ( [@attributes] => array ( [name] => bookingrq [type] => xsd:string ) ) ) [1] => array ( [@attributes] => array ( [name] => ota_hotelresrqout ) [part] => array ( [@attributes] => array ( [name] => return [type] => xsd:string ) ) ) )
)
i advise use native php soapclient class. easiest way use wsdl php generator modelize structures sent request.
you must know ota can complex call , requires understanding of rquest structure.
take @ https://www.wsdltophp.com
Comments
Post a Comment