3

I'm trying to get a response from Travelports uAPI via XML/SOAP but i'm not just getting anything useful. print_r and var_dump and an echo all just show Resource id #2 which IS something but can't get any further.

I've tried their API Test Tool to send XML requests and it works fine but just can't get it to work in PHP. I've parsed XML before but never send requests.

Code:

<?php
$CREDENTIALS = '******************';
$message = '
<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:Body>
 <air:AvailabilitySearchReq TraceId="P107788" AuthorizedBy="User" TargetBranch="P107788" xmlns:air="http://www.travelport.com/schema/air_v23_0" xmlns:com="http://www.travelport.com/schema/common_v20_0">
  <com:BillingPointOfSaleInfo OriginApplication="UAPI" /> 
 <air:SearchAirLeg>
 <air:SearchOrigin>
  <com:Airport Code="SYD" /> 
  </air:SearchOrigin>
 <air:SearchDestination>
  <com:Airport Code="MEL" /> 
  </air:SearchDestination>
  <air:SearchDepTime PreferredTime="2013-12-30" /> 
  </air:SearchAirLeg>
 <air:SearchAirLeg>
 <air:SearchOrigin>
  <com:Airport Code="MEL" /> 
  </air:SearchOrigin>
 <air:SearchDestination>
  <com:Airport Code="SYD" /> 
  </air:SearchDestination>
  <air:SearchDepTime PreferredTime="2014-01-02" /> 
  </air:SearchAirLeg>
 <air:AirSearchModifiers>
 <air:PreferredProviders>
  <com:Provider Code="1P" />
  </air:PreferredProviders>
 <air:PreferredCarriers>
  <com:Carrier Code="QF" /> 
  </air:PreferredCarriers>
  </air:AirSearchModifiers>
  <com:SearchPassenger Code="ADT" /> 
  <com:SearchPassenger Code="ADT" /> 
  </air:AvailabilitySearchReq>
  </s:Body>
  </s:Envelope>
';

$auth = $CREDENTIALS; //should base_64_encode() this!
$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/Service"); 
$header = array( 
"Content-Type: text/xml;charset=UTF-8",
"Accept: gzip,deflate",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"\"", 
"Authorization: Basic $auth",
"Content-length: ".strlen($message),
); 
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 60); 
curl_setopt($soap_do, CURLOPT_TIMEOUT, 60); 
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_exec($soap_do);



print_r($soap_do); echo '<br>';
var_dump($soap_do);
echo '<br>'.$soap_do;

?>

Any help just to get me started would be great. :)

gavenkoa
  • 45,285
  • 19
  • 251
  • 303
Tommie
  • 765
  • 6
  • 15
  • Did you get any useful results? I am unable to connect to this API too... There is a fault code at this link https://emea.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/AirService – Tehreem Dec 03 '13 at 15:35

2 Answers2

4

I am a Partner Technical Specialist at Travelport, and I understand your frustration. Our previous usage and description of endpoints has been confusing. There are updated PHP samples if you log into our developer portal; https://developer.travelport.com/app/developer-network/resource-centre-uapi

The easiest is to 'Deselect All', then select specifically for 'Sample Code'.

Give those a try!

Ted B
  • 41
  • 2
  • 1
    You answered 6 months after this thread was started, but thanks for the reply. The largest problem is that the uAPI documentation is severly lacking which makes it hard to use for more novice devs (i'm not a dev, i'm a Webdesigner/Art director with some needed PHP/SQL -knowledge). However the uAPI feels like it should be quite friendly if one only can get pass that initial confusion. My trial period has ended ages ago and i gave up trying to get anything useful out of the uAPI. Any way to get a longer trial period? – Tommie Oct 21 '14 at 11:25
  • can anybody provide document or link for travelport flight api for understanding their parameters details? – Yatin Mistry Jan 28 '16 at 10:07
2

Just change

$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/Service");

to

$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/AirService");

ParaBellum
  • 21
  • 2