I am trying to issue a SOAP request in PHP. I have my service URL, and when I check it in SOAP UI, I can see the following
<application xmlns="http://somenamespace.com">
<doc xml:lang="en" title="https://someurl.com"/>
<resources base="https://someurl.com">
<resource path="sdk/user/session/logon/" id="Logon">
<doc xml:lang="en" title="Logon"/>
<param name="ApiKey" type="xs:string" required="false" default="" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<param name="ApiSecret" type="xs:string" required="false" default="" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<method name="POST" id="Logon">
<doc xml:lang="en" title="Logon"/>
<request>
<param name="method" type="xs:string" required="true" default="" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<representation mediaType="application/json"/>
<representation mediaType="application/xml"/>
<representation mediaType="text/xml"/>
<representation mediaType="application/x-www-form-urlencoded"/>
</request>
<response status="404 500">
<representation mediaType="text/html; charset=utf-8" element="html"/>
</response>
<response status="">
<representation mediaType="application/json"/>
<representation mediaType="application/xml"/>
<representation mediaType="text/xml"/>
<representation mediaType="application/x-www-form-urlencoded"/>
</response>
<response status="500">
<representation mediaType="application/vnd.marg.bcsocial.result-v1.9+json; charset=utf-8" element="log:Fault" xmlns:log="https://someurl.com/sdk/user/session/logon"/>
<representation mediaType="application/vnd.marg.bcsocial.result-v1.9+xml; charset=utf-8" element="web:Result_1" xmlns:web="https://someurl.com/Sdk/WebService"/>
</response>
<response status="200">
<representation mediaType="application/vnd.marg.bcsocial.api.index.options.list-v2.6+xml; charset=utf-8" element="web:ListOfApiIndexOptions_4" xmlns:web="https://someurl.com/Sdk/WebService"/>
<representation mediaType="" element="data"/>
</response>
</method>
</resource>
</resources>
</application>
So I am trying to use this to log on. At the moment, I am trying something like the following
public function updateApi(){
$service_url = 'https://someurl.com/sdk/user/session/logon';
$curl = curl_init($service_url);
$curl_post_data = array(
"ApiKey" => 'somekey',
"ApiSecret" => 'somesecret',
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
curl_close($curl);
var_dump($curl_response);
}
However, I always receive a fault response that the login has failed. Do I have to call the logon method or something?
Really just looking for some advice as to whether I am doing things correctly.
Thanks
You don't set the Content-Type header telling the format of the content you posted:
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded'));
Otherwise, from php5 upwards, the usage of http_build_query is recommended:
$curl_post_data = array(
"ApiKey" => 'somekey',
"ApiSecret" => 'somesecret',
);
curl_setopt($curl, CURLOPT_POSTFIELDS,
http_build_query($curl_post_data));
Hope it helps you,
Thierry
According the XML you should try to send your curl_post_data variable as a URL Encoded string. like urlencode('ApiKey=somekey&ApiSecret=somesecret') and secondly try to set the content-type of your request to 'application/x-www-form-urlencoded'
$service_url = 'https://someurl.com/sdk/user/session/logon';
$curl = curl_init($service_url);
$headers = ["Content-Type: application/json"]; // or other supported media type
$curl_post_data = array(
"ApiKey" => 'somekey',
"ApiSecret" => 'somesecret',
);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($rest, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
curl_close($curl);
Related
I am sending the Xml request and getting the response using the CURL request function. If i send the static value i got the response But if i send the dynamic values using PHP file the response not able to get it. May i know where i mistake
Included the 2 codes
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<serve xmlns="http://schemas.cordys.com/gateway/Provider">
<SessionDoc xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.cordys.com/gateway/Provider">
<Session>
<SessionData xmlns="XXXX">
<Index>1</Index>
<InitTime>Thu, 05 Oct 17 15:55:44 +0530</InitTime>
<UserName>XXXXX</UserName>
<Password>XXXXX</Password>
<OrderNo>NA</OrderNo>
<QuoteNo>NA</QuoteNo>
<Route>INT</Route>
<Contract>XXX</Contract>
<Channel>XXX</Channel>
<TransactionType>Quote</TransactionType>
<TransactionStatus>Fresh</TransactionStatus>
<ID>XXXXXX</ID>
<UserAgentID>XXXX</UserAgentID>
<Source>XXXX</Source>
<IsCCUser>N</IsCCUser>
</SessionData>
<tns:Vehicle xmlns:tns="XXXXX">
<tns:TypeOfBusiness>TR</tns:TypeOfBusiness>
<tns:AccessoryInsured>N</tns:AccessoryInsured>
<tns:AccessoryValue>0</tns:AccessoryValue>
<tns:AntiTheftDevice>N</tns:AntiTheftDevice>
<tns:BiFuelKit>
<tns:IsBiFuelKit>N</tns:IsBiFuelKit>
<tns:BiFuelKitValue>0</tns:BiFuelKitValue>
<tns:ExternallyFitted>N</tns:ExternallyFitted>
</tns:BiFuelKit>
<tns:DateOfRegistration></tns:DateOfRegistration>
<tns:RiskType>FTW</tns:RiskType>
<tns:Make>HONDA MOTORS</tns:Make>
<tns:Model>ACTIVA</tns:Model>
<tns:FuelType>P</tns:FuelType>
<tns:Variant>3G</tns:Variant>
<tns:IDV>20202</tns:IDV>
<tns:EngineNo></tns:EngineNo>
<tns:ChasisNo></tns:ChasisNo>
<tns:DriveExperiance />
<tns:NoOfDrivers />
<tns:ParkingType />
<tns:AnnualMileage />
<tns:YoungestDriverAge />
<tns:PaidDriver />
<tns:VehicleAge>4</tns:VehicleAge>
<tns:CC>109</tns:CC>
<tns:PlaceOfRegistration>Mumbai Navi Mumbai</tns:PlaceOfRegistration>
<tns:SeatingCapacity>2</tns:SeatingCapacity>
<tns:VehicleExtraTag01 />
<tns:RegistrationNo></tns:RegistrationNo>
<tns:ExShowroomPrice>51800</tns:ExShowroomPrice>
<tns:DateOfManufacture>2014</tns:DateOfManufacture>
</tns:Vehicle>
<tns:Quote xmlns:tns="XXXXXX">
<PolicyTenure>1</PolicyTenure>
<tns:ExistingPolicy>
<tns:Claims>0</tns:Claims>
<tns:PolicyType>Comprehensive</tns:PolicyType>
<tns:EndDate></tns:EndDate>
<tns:NCB>0</tns:NCB>
<tns:PolicyNo></tns:PolicyNo>
<tns:InsuranceCompany></tns:InsuranceCompany>
</tns:ExistingPolicy>
<tns:PolicyStartDate>2017-10-06T00:00:00.000</tns:PolicyStartDate>
<tns:Deductible>0</tns:Deductible>
<tns:PAFamilySI>100000</tns:PAFamilySI>
<tns:AgentNumber>2C000002</tns:AgentNumber>
<tns:DealerId>619</tns:DealerId>
<tns:Premium>
<tns:Discount />
</tns:Premium>
<tns:SelectedCovers>
<tns:CarDamageSelected>true</tns:CarDamageSelected>
<tns:TPLiabilitySelected>true</tns:TPLiabilitySelected>
<tns:PADriverSelected>true</tns:PADriverSelected>
<tns:ZeroDepriciationSelected>false</tns:ZeroDepriciationSelected>
<tns:RoadsideAssistanceSelected>false</tns:RoadsideAssistanceSelected>
<tns:InvoicePriceSelected>false</tns:InvoicePriceSelected>
<tns:InvoicePriceCoverAmount />
<tns:PAFamilyPremiumSelected>false</tns:PAFamilyPremiumSelected>
<tns:HospitalCashSelected>false</tns:HospitalCashSelected>
<tns:MedicalExpensesSelected>false</tns:MedicalExpensesSelected>
<tns:AmbulanceChargesSelected>false</tns:AmbulanceChargesSelected>
<tns:CosumableCoverSelected>false</tns:CosumableCoverSelected>
<tns:HydrostaticLockSelected>false</tns:HydrostaticLockSelected>
<tns:KeyReplacementSelected>false</tns:KeyReplacementSelected>
<tns:NoClaimBonusSameSlabSelected>false</tns:NoClaimBonusSameSlabSelected>
<tns:EngineGearBoxProtectionSelected>false</tns:EngineGearBoxProtectionSelected>
</tns:SelectedCovers>
<tns:PolicyEndDate>2018-10-05T23:59:59.000</tns:PolicyEndDate>
</tns:Quote>
<tns:Client xmlns:tns="XXX">
<tns:ClientType>Individual</tns:ClientType>
<tns:CltDOB></tns:CltDOB>
<tns:FinancierDetails>
<tns:IsFinanced>0</tns:IsFinanced>
<tns:InstitutionName></tns:InstitutionName>
<tns:InstitutionCity></tns:InstitutionCity>
</tns:FinancierDetails>
<tns:GivName>BharatiTwo1507199144</tns:GivName>
<tns:ClientExtraTag01>MAHARASHTRA</tns:ClientExtraTag01>
<tns:CityOfResidence>Mumbai Navi Mumbai</tns:CityOfResidence>
<tns:EmailID>dfgkgj#KJhj.com</tns:EmailID>
<tns:MobileNo>9865325896</tns:MobileNo>
<tns:LandLineNo></tns:LandLineNo>
<tns:SurName></tns:SurName>
<tns:CltSex></tns:CltSex>
<tns:Marryd></tns:Marryd>
<tns:Occupation></tns:Occupation>
<tns:CltAddr01></tns:CltAddr01>
<tns:CltAddr02></tns:CltAddr02>
<tns:CltAddr03></tns:CltAddr03>
<tns:City></tns:City>
<tns:State></tns:State>
<tns:PinCode></tns:PinCode>
<tns:Nominee>
<tns:Name></tns:Name>
<tns:Age></tns:Age>
<tns:Relationship></tns:Relationship>
<tns:Appointee></tns:Appointee>
<tns:AppointeeRelation></tns:AppointeeRelation>
</tns:Nominee>
<tns:RegistrationZone>B</tns:RegistrationZone>
<GstinNo>GSTinNO</GstinNo>
</tns:Client>
<Payment>
<PaymentMode />
<PaymentType />
<TxnReferenceNo />
<TxnAmount />
<TxnDate />
<BankCode />
<InstrumentAmount />
</Payment>
</Session>
</SessionDoc>
</serve>
</SOAP:Body>
</SOAP:Envelope>';
$headers = array(
"Content-type: application/xml",
"Content-length: " . strlen($xml),
"Connection: close",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
echo "<pre>";
echo $data = curl_exec($ch); exit;
this is code for Dynamic generation using PHP Values which we passed
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<serve xmlns="http://schemas.cordys.com/gateway/Provider">
<SessionDoc xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.cordys.com/gateway/Provider">
<Session>
<SessionData xmlns="XXX">
<Index>'.$stage.'</Index>
<InitTime>'.$current_date.'</InitTime>
<UserName>XXXXX</UserName>
<Password>XXXX</Password>
<OrderNo>'.$order_no.'</OrderNo>
<QuoteNo>'.$quote_no.'</QuoteNo>
<Route>INT</Route>
<Contract>MTR</Contract>
<Channel>XXXX</Channel>
<TransactionType>Quote</TransactionType>
<TransactionStatus>Fresh</TransactionStatus>
<ID>XXXXX</ID>
<UserAgentID>2C000002</UserAgentID>
<Source>2C000002</Source>
<IsCCUser>N</IsCCUser>
</SessionData>
<tns:Vehicle xmlns:tns="XXX">
<tns:TypeOfBusiness>'.$bis_type.'</tns:TypeOfBusiness>
<tns:AccessoryInsured>'.$access_ins.'</tns:AccessoryInsured>
<tns:AccessoryValue>'.$access_val.'</tns:AccessoryValue>
<tns:AntiTheftDevice>'.$anti_thfdev.'</tns:AntiTheftDevice>
<tns:BiFuelKit>
<tns:IsBiFuelKit>'.$fuel_kit.'</tns:IsBiFuelKit>
<tns:BiFuelKitValue>'.$fuel_kit_val.'</tns:BiFuelKitValue>
<tns:ExternallyFitted>'.$ext_fit.'</tns:ExternallyFitted>
</tns:BiFuelKit>
<tns:DateOfRegistration>'.$veh_reg_date.'</tns:DateOfRegistration>
<tns:RiskType>'.$risktype.'</tns:RiskType>
<tns:Make>'.$make.'</tns:Make>
<tns:Model>'.$model.'</tns:Model>
<tns:FuelType>'.$fuel_type.'</tns:FuelType>
<tns:Variant>'.$variant.'</tns:Variant>
<tns:IDV>'.$idv.'</tns:IDV>
<tns:EngineNo>'.$engine_no.'</tns:EngineNo>
<tns:ChasisNo>'.$chasis_no.'</tns:ChasisNo>
<tns:DriveExperiance />
<tns:NoOfDrivers />
<tns:ParkingType />
<tns:AnnualMileage />
<tns:YoungestDriverAge />
<tns:PaidDriver />
<tns:VehicleAge>'.$veh_age.'</tns:VehicleAge>
<tns:CC>'.$cc.'</tns:CC>
<tns:PlaceOfRegistration>'.$place_reg.'</tns:PlaceOfRegistration>
<tns:SeatingCapacity>'.$seating.'</tns:SeatingCapacity>
<tns:VehicleExtraTag01 />
<tns:RegistrationNo>'.$veh_number.'</tns:RegistrationNo>
<tns:ExShowroomPrice>'.$x_shw_prc.'</tns:ExShowroomPrice>
<tns:DateOfManufacture>'.$mnf_year.'</tns:DateOfManufacture>
</tns:Vehicle>
<tns:Quote xmlns:tns="XXXX">
<PolicyTenure>'.$policy_tenure.'</PolicyTenure>
<tns:ExistingPolicy>
<tns:Claims>0</tns:Claims>
<tns:PolicyType>Comprehensive</tns:PolicyType>
<tns:EndDate>'.$ext_policy_enddate.'</tns:EndDate>
<tns:NCB>'.$ncb_val.'</tns:NCB>
<tns:PolicyNo>'.$policy_no.'</tns:PolicyNo>
<tns:InsuranceCompany>'.$ins_cmp.'</tns:InsuranceCompany>
</tns:ExistingPolicy>
<tns:PolicyStartDate>'.$policy_stdate.'</tns:PolicyStartDate>
<tns:Deductible>'.$deductable.'</tns:Deductible>
<tns:PAFamilySI>100000</tns:PAFamilySI>
<tns:AgentNumber>2C000002</tns:AgentNumber>
<tns:DealerId>619</tns:DealerId>
<tns:Premium>
<tns:Discount />
</tns:Premium>
<tns:SelectedCovers>
<tns:CarDamageSelected>true</tns:CarDamageSelected>
<tns:TPLiabilitySelected>true</tns:TPLiabilitySelected>
<tns:PADriverSelected>true</tns:PADriverSelected>
<tns:ZeroDepriciationSelected>'.$addons_list['DEPC'].'</tns:ZeroDepriciationSelected>
<tns:RoadsideAssistanceSelected>'.$addons_list['RSAC'].'</tns:RoadsideAssistanceSelected>
<tns:InvoicePriceSelected>'.$addons_list['INPC'].'</tns:InvoicePriceSelected>
<tns:InvoicePriceCoverAmount />
<tns:PAFamilyPremiumSelected>'.$addons_list['PAFamily'].'</tns:PAFamilyPremiumSelected>
<tns:HospitalCashSelected>'.$addons_list['HOSP'].'</tns:HospitalCashSelected>
<tns:MedicalExpensesSelected>'.$addons_list['MEDI'].'</tns:MedicalExpensesSelected>
<tns:AmbulanceChargesSelected>'.$addons_list['AMBC'].'</tns:AmbulanceChargesSelected>
<tns:CosumableCoverSelected>'.$addons_list['CONC'].'</tns:CosumableCoverSelected>
<tns:HydrostaticLockSelected>'.$addons_list['HYLC'].'</tns:HydrostaticLockSelected>
<tns:KeyReplacementSelected>'.$addons_list['KEYC'].'</tns:KeyReplacementSelected>
<tns:NoClaimBonusSameSlabSelected>'.$addons_list['NCBS'].'</tns:NoClaimBonusSameSlabSelected>
<tns:EngineGearBoxProtectionSelected>'.$addons_list['EGBP'].'</tns:EngineGearBoxProtectionSelected>
</tns:SelectedCovers>
<tns:PolicyEndDate>'.$policy_endate.'</tns:PolicyEndDate>
</tns:Quote>
<tns:Client xmlns:tns="XXXX">
<tns:ClientType>Individual</tns:ClientType>
<tns:CltDOB>'.$clnt_dob.'</tns:CltDOB>
<tns:FinancierDetails>
<tns:IsFinanced>'.$is_fin.'</tns:IsFinanced>
<tns:InstitutionName>'.$fin_name.'</tns:InstitutionName>
<tns:InstitutionCity>'.$fin_city.'</tns:InstitutionCity>
</tns:FinancierDetails>
<tns:GivName>'.$first_name.'</tns:GivName>
<tns:ClientExtraTag01>'.$reg_state.'</tns:ClientExtraTag01>
<tns:CityOfResidence>'.$rto.'</tns:CityOfResidence>
<tns:EmailID>'.$email_id.'</tns:EmailID>
<tns:MobileNo>'.$mobile_no.'</tns:MobileNo>
<tns:LandLineNo>'.$emg_cnt_no.'</tns:LandLineNo>
<tns:SurName>'.$last_name.'</tns:SurName>
<tns:CltSex>'.$gender.'</tns:CltSex>
<tns:Marryd>'.$martial_status.'</tns:Marryd>
<tns:Occupation>'.$occup.'</tns:Occupation>
<tns:CltAddr01>'.$addr1.'</tns:CltAddr01>
<tns:CltAddr02>'.$addr2.'</tns:CltAddr02>
<tns:CltAddr03>'.$landmark.'</tns:CltAddr03>
<tns:City>'.$city.'</tns:City>
<tns:State>'.$state.'</tns:State>
<tns:PinCode>'.$pincode.'</tns:PinCode>
<tns:Nominee>
<tns:Name>'.$nom_name.'</tns:Name>
<tns:Age>'.$nom_age.'</tns:Age>
<tns:Relationship>'.$nom_rel.'</tns:Relationship>
<tns:Appointee>'.$nom_apnt.'</tns:Appointee>
<tns:AppointeeRelation>'.$nom_apnt_rel.'</tns:AppointeeRelation>
</tns:Nominee>
<tns:RegistrationZone>'.$reg_zone.'</tns:RegistrationZone>
<GstinNo></GstinNo>
</tns:Client>
<Payment>
<PaymentMode />
<PaymentType />
<TxnReferenceNo />
<TxnAmount />
<TxnDate />
<BankCode />
<InstrumentAmount />
</Payment>
</Session>
</SessionDoc>
</serve>
</SOAP:Body>
</SOAP:Envelope>';
$headers = array(
"Content-type: application/xml",
"Content-length: " . strlen($xml),
"Connection: close",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
Where i did wrong here. Please clear me
I have got XML response from curl and trying to search some tag value but I am failing. Kindly somebody help me
Please bare as I am new to the PHP
<?php
$DynamicValue = 'KWI';
$url='https://www.example.com/_api/web/lists/getbytitle(\'Stations\')/items?$select=OfficeId&$filter='.urlencode("CityCode eq '" . $DynamicValue . "'");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/xml"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$XML = new SimpleXMLElement($result);
foreach($XML->entry as $value)
{
echo $value->OfficeId
}
Output:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="https://www.example.com/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>a9f073a2-387e-4ac5-81b9-16b3ae81dba3</id><title /><updated>2017-03-20T08:15:47Z</updated><entry m:etag=""61""><id>Web/Lists(guid'5344b09b-d3f7-44ec-bd52-a8f5a99f23f9')/Items(23)</id><category term="SP.Data.StationsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid'5344b09b-d3f7-44ec-bd52-a8f5a99f23f9')/Items(23)" /><title /><updated>2017-03-20T08:15:47Z</updated><author><name /></author><content type="application/xml"><m:properties><d:OfficeId>KWIKU08AA</d:OfficeId></m:properties></content></entry></feed>
Hope this will work.
$string='<?xml version="1.0" encoding="utf-8"?><feed xml:base="https://www.example.com/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>a9f073a2-387e-4ac5-81b9-16b3ae81dba3</id><title /><updated>2017-03-20T08:15:47Z</updated><entry m:etag=""61""><id>Web/Lists(guid\'5344b09b-d3f7-44ec-bd52-a8f5a99f23f9\')/Items(23)</id><category term="SP.Data.StationsListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid\'5344b09b-d3f7-44ec-bd52-a8f5a99f23f9\')/Items(23)" /><title /><updated>2017-03-20T08:15:47Z</updated><author><name /></author><content type="application/xml"><m:properties><d:OfficeId>KWIKU08AA</d:OfficeId></m:properties></content></entry></feed>';
echo explode("</d:OfficeId>",explode("<d:OfficeId>", $string)[1])[0];
PHP Code demo
I am currently using CURL in PHP to request XML. When using same flow in POSTMAN service I can get the success result but, when using CURL in PHP I get CODE - UC SEG STATUS NOT ALLOWED-0003 status. Below are my CURL request header and code. Is my header option in CURL request making the problem?
function get_xml_response($xmldata) {
error_reporting(E_ALL);
$wsdl = 'https://sws3-crt.cert.sabre.com';
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"\"",
"Content-length: " . strlen($xmldata),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "$wsdl");
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_setopt($soap_do, CURLOPT_FRESH_CONNECT, TRUE);
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, $xmldata);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
if (curl_exec($soap_do) === false) {
$err = 'Curl error: ' . curl_error($soap_do);
curl_close($soap_do);
print $err;
return false;
} else {
$response = curl_exec($soap_do);
$httpcode = curl_getinfo($soap_do, CURLINFO_HTTP_CODE);
return $response;
}
}
EnhancedBookRQ.xml
<?xml version="1.0" encoding="utf-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader">
<eb:From>
<eb:PartyId eb:type="urn:x12.org.IO5:01">info#gandakiintl.com</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
</eb:To>
<eb:ConversationId>111#gandakiintl.com</eb:ConversationId>
<eb:Service eb:type="SabreXML">Enhanced Air Book Request</eb:Service>
<eb:Action>EnhancedAirBookRQ</eb:Action>
<eb:CPAID>T198</eb:CPAID>
<eb:MessageData>
<eb:MessageId>mid:11110info#gandakiintl.com</eb:MessageId>
<eb:Timestamp>2016-10-17T05-27-10Z</eb:Timestamp>
<eb:TimeToLive>2016-10-17T05-27-10Z</eb:TimeToLive>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:BinarySecurityToken>Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTD!ICESMSLB\/CRT.LB!-3322625022286234335!532307!0</wsse:BinarySecurityToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<EnhancedAirBookRQ xmlns="http://services.sabre.com/sp/eab/v3_6" version="3.6.0" HaltOnError="true">
<OTA_AirBookRQ>
<HaltOnStatus Code="UC"/>
<HaltOnStatus Code="LL"/>
<HaltOnStatus Code="UL"/>
<HaltOnStatus Code="UN"/>
<HaltOnStatus Code="NO"/>
<HaltOnStatus Code="HL"/>
<OriginDestinationInformation>
<FlightSegment NumberInParty="1" Status="NN" FlightNumber="281" ResBookDesigCode="W" DepartureDateTime="2017-04-13T13:10:00" ArrivalDateTime="2017-04-13T14:40:00">
<DestinationLocation LocationCode="DEL"/>
<Equipment AirEquipType="73H"/>
<MarketingAirline FlightNumber="281" Code="9W"/>
<OriginLocation LocationCode="KTM"/>
</FlightSegment>
</OriginDestinationInformation>
</OTA_AirBookRQ>
<OTA_AirPriceRQ>
<PriceRequestInformation Retain="true">
<OptionalQualifiers>
<FlightQualifiers>
<VendorPrefs>
<Airline Code="9W"/>
</VendorPrefs>
</FlightQualifiers>
<PricingQualifiers CurrencyCode="NPR">
<PassengerType Code="ADT" Force="true" Quantity="1"/>
<Taxes>
<TaxExempt Code="NQ"/>
</Taxes>
</PricingQualifiers>
</OptionalQualifiers>
</PriceRequestInformation>
</OTA_AirPriceRQ>
<PostProcessing IgnoreAfter="false">
<RedisplayReservation/>
</PostProcessing>
<PreProcessing IgnoreBefore="false"> </PreProcessing>
</EnhancedAirBookRQ>
</soap-env:Body>
</soap-env:Envelope>
EnhancedBookRS.xml
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader" eb:version="1.0" soap-env:mustUnderstand="1">
<eb:From>
<eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:x12.org.IO5:01">info#gandakiintl.com</eb:PartyId>
</eb:To>
<eb:CPAId>T198</eb:CPAId>
<eb:ConversationId>111#gandakiintl.com</eb:ConversationId>
<eb:Service eb:type="SabreXML">Enhanced Air Book Request</eb:Service>
<eb:Action>EnhancedAirBookRS</eb:Action>
<eb:MessageData>
<eb:MessageId>bk97jgyj2</eb:MessageId>
<eb:Timestamp>2017-01-03T06:01:43</eb:Timestamp>
<eb:RefToMessageId>mid:11110info#gandakiintl.com</eb:RefToMessageId>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:BinarySecurityToken valueType="String" EncodingType="wsse:Base64Binary">Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTD!ICESMSLB\/CRT.LB!-3322625022286234335!532307!0</wsse:BinarySecurityToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<EnhancedAirBookRS xmlns="http://services.sabre.com/sp/eab/v3_6">
<ns2:ApplicationResults xmlns:ns2="http://services.sabre.com/STL_Payload/v02_01" status="NotProcessed">
<ns2:Error type="BusinessLogic" timeStamp="2017-01-03T00:01:43.090-06:00">
<ns2:SystemSpecificResults>
<ns2:Message code="ERR.SWS.HOST.ERROR_IN_RESPONSE">CODE - UC SEG STATUS NOT ALLOWED-0003</ns2:Message>
</ns2:SystemSpecificResults>
</ns2:Error>
</ns2:ApplicationResults>
<OTA_AirBookRS>
<OriginDestinationOption>
<FlightSegment ArrivalDateTime="04-13T14:40" DepartureDateTime="04-13T13:10" FlightNumber="0281" NumberInParty="001" ResBookDesigCode="W" Status="NN" eTicket="true">
<DestinationLocation LocationCode="DEL"/>
<MarketingAirline Code="9W" FlightNumber="0281"/>
<OriginLocation LocationCode="KTM"/>
</FlightSegment>
</OriginDestinationOption>
</OTA_AirBookRS>
<TravelItineraryReadRS>
<TravelItinerary>
<CustomerInfo/>
<ItineraryInfo>
<ItineraryPricing>
<PriceQuote RPH="1">
<MiscInformation>
<SignatureLine ExpirationDateTime="00:00" Source="SYS" Status="ACTIVE">
<Text>T198 T198*AGT 1131/03JAN17</Text>
</SignatureLine>
<TicketingFees Disclaimer="ONE OR MORE FORM OF PAYMENT FEES MAY APPLY"/>
<TicketingFees Disclaimer="ACTUAL TOTAL WILL BE BASED ON FORM OF PAYMENT USED"/>
<TicketingFees Disclaimer="FEE CODE DESCRIPTION FEE">
<FeeInformation Amount="399" CurrenyCode="" Description="" FunctionCode="FCA" ServiceType="OB">- ANY CC</FeeInformation>
</TicketingFees>
</MiscInformation>
<PricedItinerary DisplayOnly="false" InputMessage="WPA9WMNPRP1ADTXOTE-NQRQ" RPH="1" StatusCode="A" TaxExempt="false" ValidatingCarrier="9W">
<AirItineraryPricingInfo>
<ItinTotalFare>
<BaseFare Amount="3425" CurrencyCode="NPR"/>
<Taxes>
<Tax Amount="6377" TaxCode="XT"/>
<TaxBreakdownCode TaxPaid="false">0NQ</TaxBreakdownCode>
<TaxBreakdownCode TaxPaid="false">791NP</TaxBreakdownCode>
<TaxBreakdownCode TaxPaid="false">1000B6</TaxBreakdownCode>
<TaxBreakdownCode TaxPaid="false">1159IN</TaxBreakdownCode>
<TaxBreakdownCode TaxPaid="false">3427YQ</TaxBreakdownCode>
</Taxes>
<TotalFare Amount="9802" CurrencyCode="NPR"/>
<Totals>
<BaseFare Amount="3425"/>
<Taxes>
<Tax Amount="6377"/>
</Taxes>
<TotalFare Amount="9802"/>
</Totals>
</ItinTotalFare>
<PassengerTypeQuantity Code="ADT" Quantity="01"/>
<PTC_FareBreakdown>
<Endorsements>
<Endorsement type="SYSTEM_ENDORSEMENT">
<Text>NON ENDO</Text>
</Endorsement>
<Endorsement type="PRICING_PARAMETER">
<Text>WPA9W$MNPR$P1ADT$XO$TE-NQ$RQ</Text>
</Endorsement>
<Endorsement type="WARNING">
<Text>VALIDATING CARRIER SPECIFIED - 9W</Text>
</Endorsement>
</Endorsements>
<FareBasis Code="W2STOWNP"/>
<FareCalculation>
<Text>KTM 9W DEL Q15.00 16.61NUC31.61END ROE108.347088</Text>
</FareCalculation>
<FareSource>ATPC</FareSource>
<FlightSegment ConnectionInd="O" DepartureDateTime="04-13T13:10" FlightNumber="281" ResBookDesigCode="W" SegmentNumber="1" Status="OK">
<BaggageAllowance Number="20K"/>
<FareBasis Code="W2STOWNP"/>
<MarketingAirline Code="9W" FlightNumber="281"/>
<OriginLocation LocationCode="KTM"/>
<ValidityDates>
<NotValidAfter>2017-04-13</NotValidAfter>
<NotValidBefore>2017-04-13</NotValidBefore>
</ValidityDates>
</FlightSegment>
<FlightSegment>
<OriginLocation LocationCode="DEL"/>
</FlightSegment>
<ResTicketingRestrictions>LAST DAY TO PURCHASE 10JAN/2359</ResTicketingRestrictions>
<ResTicketingRestrictions>GUARANTEED FARE APPL IF PURCHASED BEFORE 10JAN</ResTicketingRestrictions>
</PTC_FareBreakdown>
</AirItineraryPricingInfo>
</PricedItinerary>
<ResponseHeader>
<Text>FARE - PRICE RETAINED</Text>
<Text>FARE USED TO CALCULATE DISCOUNT</Text>
<Text>FARE NOT GUARANTEED UNTIL TICKETED</Text>
</ResponseHeader>
<PriceQuotePlus DiscountAmount="0" DisplayOnly="false" DomesticIntlInd="I" IT_BT_Fare="BT" ItineraryChanged="false" ManualFare="false" NUCSuppresion="false" NegotiatedFare="false" PricingStatus="M" SubjToGovtApproval="false" SystemIndicator="S" VerifyFareCalc="false">
<TicketingInstructionsInfo/>
</PriceQuotePlus>
</PriceQuote>
<PriceQuoteTotals>
<BaseFare Amount="3425.00"/>
<Taxes>
<Tax Amount="6377.00"/>
</Taxes>
<TotalFare Amount="9802.00"/>
</PriceQuoteTotals>
</ItineraryPricing>
<ReservationItems>
<Item RPH="1">
<FlightSegment AirMilesFlown="0507" ArrivalDateTime="04-13T14:40" DayOfWeekInd="4" DepartureDateTime="2017-04-13T13:10" ElapsedTime="01.45" FlightNumber="0281" IsPast="false" NumberInParty="01" ResBookDesigCode="W" SegmentNumber="0001" SmokingAllowed="false" SpecialMeal="false" Status="SS" StopQuantity="00" eTicket="true">
<DestinationLocation LocationCode="DEL" Terminal="TERMINAL 3" TerminalCode="3"/>
<Equipment AirEquipType="73H"/>
<MarketingAirline Code="9W" FlightNumber="0281"/>
<Meal Code="L"/>
<OriginLocation LocationCode="KTM"/>
<SupplierRef ID="DC9W"/>
<UpdatedArrivalTime>04-13T14:40</UpdatedArrivalTime>
<UpdatedDepartureTime>04-13T13:10</UpdatedDepartureTime>
</FlightSegment>
</Item>
<Item RPH="2">
<FlightSegment AirMilesFlown="0507" ArrivalDateTime="04-13T14:40" DayOfWeekInd="4" DepartureDateTime="2017-04-13T13:10" ElapsedTime="01.45" FlightNumber="0281" IsPast="false" NumberInParty="01" ResBookDesigCode="W" SegmentNumber="0002" SmokingAllowed="false" SpecialMeal="false" Status="UC" StopQuantity="00" eTicket="false">
<DestinationLocation LocationCode="DEL" Terminal="TERMINAL 3" TerminalCode="3"/>
<Equipment AirEquipType="73H"/>
<MarketingAirline Code="9W" FlightNumber="0281"/>
<Meal Code="L"/>
<OriginLocation LocationCode="KTM"/>
<SupplierRef ID="DC9W"/>
<UpdatedArrivalTime>04-13T14:40</UpdatedArrivalTime>
<UpdatedDepartureTime>04-13T13:10</UpdatedDepartureTime>
</FlightSegment>
</Item>
</ReservationItems>
</ItineraryInfo>
<ItineraryRef AirExtras="false" InhibitCode="U" PartitionID="AA" PrimeHostID="1B">
<Header>CURRENTLY DISPLAYING A PNR OWNED BY THE SABRE PRIME HOST</Header>
<Header>RULES AND FUNCTIONALITY FOR THAT PRIME HOST WILL APPLY</Header>
<Header>PRICE QUOTE RECORD - MODIFIED</Header>
<Source PseudoCityCode="T198"/>
</ItineraryRef>
<SpecialServiceInfo RPH="001" Type="GFX">
<Service SSR_Code="OSI">
<Airline Code="1B"/>
<Text>PLEASE TICKET FARE AS PER TKT/TL IN PQ</Text>
</Service>
</SpecialServiceInfo>
</TravelItinerary>
</TravelItineraryReadRS>
</EnhancedAirBookRS>
</soap-env:Body>
</soap-env:Envelope>
I have to check your code, One thing is that if you getting your result from postman .. Then there is a good option for getting curl code from the postman. By click on code > change HTTP option to PHP curl >copy to clipboard . If you try with this way of write code, you have to change little changes.
And one more thing, A very good answer have given here UC status . UC status related to UN-CONFIRMED status. Please have a look here. Thanks
This is an example , for how to pass your post field data in xml form :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => "",
CURLOPT_URL => "url here",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soap:Body> soap body part </soap:Body>\n</soap:Envelope>",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: text/xml"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
I have tried you code and modified some part of it. please try using below code
<?php
header('Content-Type: application/xml');
$xmldata='<?xml version="1.0" encoding="utf-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<eb:MessageHeader xmlns:eb="http://www.ebxml.org/namespaces/messageHeader">
<eb:From>
<eb:PartyId eb:type="urn:x12.org.IO5:01">info#gandakiintl.com</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId eb:type="urn:x12.org.IO5:01">webservices.sabre.com</eb:PartyId>
</eb:To>
<eb:ConversationId>111#gandakiintl.com</eb:ConversationId>
<eb:Service eb:type="SabreXML">Enhanced Air Book Request</eb:Service>
<eb:Action>EnhancedAirBookRQ</eb:Action>
<eb:CPAID>T198</eb:CPAID>
<eb:MessageData>
<eb:MessageId>mid:11110info#gandakiintl.com</eb:MessageId>
<eb:Timestamp>2016-10-17T05-27-10Z</eb:Timestamp>
<eb:TimeToLive>2016-10-17T05-27-10Z</eb:TimeToLive>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
<wsse:BinarySecurityToken>Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/ACPCRTD!ICESMSLB\/CRT.LB!-3322625022286234335!532307!0</wsse:BinarySecurityToken>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<EnhancedAirBookRQ xmlns="http://services.sabre.com/sp/eab/v3_6" version="3.6.0" HaltOnError="true">
<OTA_AirBookRQ>
<HaltOnStatus Code="UC"/>
<HaltOnStatus Code="LL"/>
<HaltOnStatus Code="UL"/>
<HaltOnStatus Code="UN"/>
<HaltOnStatus Code="NO"/>
<HaltOnStatus Code="HL"/>
<OriginDestinationInformation>
<FlightSegment NumberInParty="1" Status="NN" FlightNumber="281" ResBookDesigCode="W" DepartureDateTime="2017-04-13T13:10:00" ArrivalDateTime="2017-04-13T14:40:00">
<DestinationLocation LocationCode="DEL"/>
<Equipment AirEquipType="73H"/>
<MarketingAirline FlightNumber="281" Code="9W"/>
<OriginLocation LocationCode="KTM"/>
</FlightSegment>
</OriginDestinationInformation>
</OTA_AirBookRQ>
<OTA_AirPriceRQ>
<PriceRequestInformation Retain="true">
<OptionalQualifiers>
<FlightQualifiers>
<VendorPrefs>
<Airline Code="9W"/>
</VendorPrefs>
</FlightQualifiers>
<PricingQualifiers CurrencyCode="NPR">
<PassengerType Code="ADT" Force="true" Quantity="1"/>
<Taxes>
<TaxExempt Code="NQ"/>
</Taxes>
</PricingQualifiers>
</OptionalQualifiers>
</PriceRequestInformation>
</OTA_AirPriceRQ>
<PostProcessing IgnoreAfter="false">
<RedisplayReservation/>
</PostProcessing>
<PreProcessing IgnoreBefore="false"> </PreProcessing>
</EnhancedAirBookRQ>
</soap-env:Body>
</soap-env:Envelope>';
error_reporting(E_ALL);
$wsdl = 'https://sws3-crt.cert.sabre.com';
$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"\"",
"Content-length: " . strlen($xmldata),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$err = curl_error($ch);
print_r($response);
print_r($err);
?>
UC status means that the itinerary you booked is not available. It could be due to a number of different things like date, class of service, etc.
Where did you get the itinerary information from? If you're using a shopping service, I'd advise you to run it again and see if the same itinerary is still returned, or if the class of service changed.
Write xml content to a file named is soap_this.xml and using curl command to send request:
curl -X POST --header "Content-Type:text/xml;charset=UTF-8" --data #soap_get.xml your_url
That because by the time you creating pnr request, there might not be a available flight for your requesting cabin type. Even though atleast one flight sector has unavailability Sabre does not allow to create pnr
Using following Sabre commands you can check availability of flight segments
More details about commands: http://www.emquest.ae/downloads/STM/Quick%20Reference%20English.pdf
In your Request you have set this option:
<HaltOnStatus Code="UC"/>
<HaltOnStatus Code="LL"/>
<HaltOnStatus Code="UL"/>
<HaltOnStatus Code="UN"/>
<HaltOnStatus Code="NO"/>
<HaltOnStatus Code="HL"/>
which means if the segment that you are trying to sell is not confirmed because of availability etc then end the transaction.
I don't know the sabre api, but it Looks like you malformed the request with the segement UC.
Try to look in the api docs or try to contact the help desk.
In the sample request there es is no <haltonstatus/>, Look here
https://developer.sabre.com/docs/read/soap_apis/air/book/orchestrated_air_booking
Hi guys can anyone have an idea of how to create this request in php. Am invoking a .net soap web-service.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<confirmCustomerReq xmlns="http://www.nrs.eskom.co.za/xmlvend/revenue/2.1/schema">
<clientID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<terminalID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<msgID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" dateTime="xx" uniqueNumber="xx" />
<authCred xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema">
<opName>xxx</opName>
<password>xxx##1</password>
</authCred>
<idMethod xmlns:q1="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="q1:VendIDMethod">
<q1:meterIdentifier xsi:type="q1:MeterNumber" msno="xx" />
</idMethod>
</confirmCustomerReq>
</soap:Body>
</soap:Envelope>
I tried using SoapClient class and curl but still couldn't get the exact xml below is my the snippet of my code. below was using SoapClient class
array( 'ConfirmCustomerReq'=>array(
'ClientID' =>array('xsi:type'=>"EANDeviceID", 'ean'=>"xxxx"),
'terminalID'=>array('xsi:type'=>"EANDeviceID", 'ean'=>"xxx"),
'authCred' => array(
'opName' => "$this->username",
'password' => "$this->pass"
),
'msgID' => array('dateTime'=>"xxx" ,'uniqueNumber'=>"xxx" ),
'idMethod' => array('xsi:type'=>"q1:VendIDMethod",
'meterIdentifier' =>array( 'xsi:type'=>"q1:MeterNumber" ,'msno'=>"xxx")
)
)
);
and curl
function main(){
$xml ='<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<confirmCustomerReq xmlns="http://www.nrs.eskom.co.za/xmlvend/revenue/2.1/schema">
<clientID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<terminalID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
<msgID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" dateTime="xx" uniqueNumber="xx" />
<authCred xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema">
<opName>xxx</opName>
<password>xxx##1</password>
</authCred>
<idMethod xmlns:q1="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="q1:VendIDMethod">
<q1:meterIdentifier xsi:type="q1:MeterNumber" msno="xx" />
</idMethod>
</confirmCustomerReq>
</soap:Body>
</soap:Envelope>';
try{
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "https://www.utilitiesworld.co.za/SecureThirdPartyInterface/VendingService.asmx" );
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($soap_do, CURLOPT_CAINFO, 'XXXXXXXXXXXXXX');
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml);
//curl_setopt($soap_do, CURLOPT_HEADER, false);
$xml_result = curl_exec($soap_do);
echo curl_error($soap_do);
//$result=parse_str($xml_result);
//var_dump($xml_result);
curl_close($soap_do);
}
soap client modual is exist in php
http://php.net/manual/en/soapclient.soapclient.php
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. :)
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!
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");