soap - Travelport uAPI using Php soapClient -
having issue using php soapclient access travelport uapi.
able use curl data not able use air.wsdl file hit travelport.
currently using latest air.wsdl file released on 1st of july 2015.
anyone got working example on how done?
travelportprovider:
namespace providers; use providers\clients\soapclient; class travelportprovider extends soapclient { public function __construct() { parent::__construct(config('travelport.airwsdl'), config('travelport.endpoint')); } public function search() { return $this->service(); } public function service() { $parameters = array( 'billingpointofsaleinfo' => array( 'originapplication' => 'uapi' ), 'airpricingsolution' => array( 'key' => 1 ), 'legs' => array( 'key' => 1, 'group' => 1, 'origin' => 'bne', 'destination' => 'syd', 'departuredate' => '2015-07-23', 'cabinclass' => 'economy', 'validationpassed:protected' => '1', 'validationerrors:protected' => '' ) ); $response = $this->__soapcall('service', array($parameters)); return $response; } } soapclient:
namespace providers\clients; abstract class soapclient extends \soapclient { /** * configuration array * * @var array */ protected $config = null; /** * options array * * @var array */ protected $options = null; public function __construct($wsdl, $endpoint, $options = null) { // set soap config $this->setconfig($wsdl, $endpoint); // set soap context $this->setcontext(); // create classmap array // $this->setclassmap(); // set soap options $this->setoptions($this->config, $this->context); // set wsdl endpoint $this->__setlocation($endpoint); // create soapclient parent::__construct($wsdl, $this->options); } /** * set soap config * * @param string $wsdl * @param string $endpoint * @return array $config */ protected function setconfig($wsdl, $endpoint) { // check wsdl if ($wsdl == null) { throw new \soapexception("wsdl cannot null"); } // credentials $this->config = array( 'username' => config('travelport.username'), 'password' => config('travelport.password'), 'credentials' => config('travelport.credentials'), 'wsdl' => $wsdl, 'endpoint' => $endpoint ); // setting config return $this->config; } /** * set soap context * * @return array $context */ protected function setcontext() { $this->context = array( 'http' => array( 'header' => array( 'content-type: text / xml; charset = utf-8', 'accept-encoding: gzip, deflate', 'soapaction: ""' )), 'ssl' => array( 'ciphers' => 'rc4-sha' ) ); return $this->context; } /** * set soap options * * @param array $config * @param array $context * @return array $options */ protected function setoptions($config, $context) { $this->options = array( 'soap_version' => 'soap_1_1', 'encoding' => 'utf-8', 'exceptions' => true, 'stream_context' => stream_context_create($context), 'trace' => true, 'login' => $config['username'], 'password' => $config['password'] ); // setting options return $this->options; } } what found interesting latest air.wsdl file has same operation name "service" same input/output names well. how choose 1 target, want search lowfaresearch?
i did $this->__getfunction() , getting following
array ( [0] => airrepricersp service(airrepricereq $parameters) [1] => schedulesearchrsp service(schedulesearchreq $parameters) [2] => lowfaresearchrsp service(lowfaresearchreq $parameters) [3] => lowfaresearchasynchrsp service(lowfaresearchasynchreq $parameters) [4] => retrievelowfaresearchrsp service(retrievelowfaresearchreq $parameters) [5] => airpricersp service(airpricereq $parameters) [6] => airfarerulesrsp service(airfarerulesreq $parameters) [7] => availabilitysearchrsp service(availabilitysearchreq $parameters) [8] => airfaredisplayrsp service(airfaredisplayreq $parameters) [9] => seatmaprsp service(seatmapreq $parameters) [10] => airrefundquotersp service(airrefundquotereq $parameters) [11] => airrefundrsp service(airrefundreq $parameters) [12] => airticketingrsp service(airticketingreq $parameters) [13] => airvoiddocumentrsp service(airvoiddocumentreq $parameters) [14] => airretrievedocumentrsp service(airretrievedocumentreq $parameters) [15] => airexchangersp service(airexchangereq $parameters) [16] => airexchangequotersp service(airexchangequotereq $parameters) [17] => airexchangeticketingrsp service(airexchangeticketingreq $parameters) [18] => airmerchandisingofferavailabilityrsp service(airmerchandisingofferavailabilityreq $parameters) [19] => airupsellsearchrsp service(airupsellsearchreq $parameters) [20] => flighttimetablersp service(flighttimetablereq $parameters) [21] => airprepayrsp service(airprepayreq $parameters) [22] => emdretrieversp service(emdretrievereq $parameters) [23] => emdissuancersp service(emdissuancereq $parameters) [24] => airmerchandisingdetailsrsp service(airmerchandisingdetailsreq $parameters) [25] => flightinformationrsp service(flightinformationreq $parameters) [26] => flightdetailsrsp service(flightdetailsreq $parameters) )
if want use wsdl, must copy original wsdl file , put in description of 1 service. each of desired service. if need 2 of air.wsdl service, have 2 separate wsdl files. example airmerchandisingofferavailabilityrsp:
<?xml version="1.0" encoding="utf-8"?> <definitions name="airservice" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.travelport.com/service/air_v32_0" xmlns:ns1="http://www.travelport.com/schema/air_v32_0" targetnamespace="http://www.travelport.com/service/air_v32_0"> <import namespace="http://www.travelport.com/service/air_v32_0" location="airabstract.wsdl" /> <binding name="airmerchandisingofferavailabilitybinding" type="tns:airmerchandisingofferavailabilityporttype"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="service"> <soap:operation soapaction="http://localhost:8080/kestrel/airservice"/> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> <fault name="errorinfomsg"> <soap:fault name="errorinfomsg" use="literal" /> </fault> </operation> </binding> <!-- service --> <service name="airservice"> <port name="airmerchandisingofferavailabilityport" binding="tns:airmerchandisingofferavailabilitybinding"> <soap:address location="http://localhost:8080/kestrel/airservice" /> </port> </service> </definitions> i did so.
Comments
Post a Comment