Reputation: 783
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. :)
Upvotes: 3
Views: 3644
Reputation: 41
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!
Upvotes: 4
Reputation: 21
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");
Upvotes: 2