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
Related
I am attempting to authenticate to a Sharepoint Online instance with an obtained security token for an account. I have found various places discussing this but get hung up when actually trying to pass the token to sharepoint to login.
Here is my code to obtain the security token (which is working)
$xml = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To>
<o:Security s:mustUnderstand="1"
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken>
<o:Username>MYUSERNAME</o:Username>
<o:Password>MYPASSWORD</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>https://MYSHAREPOINTINSTANCE.sharepoint.com/</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>';
$curl = curl_init("https://login.microsoftonline.com/extSTS.srf");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-Type: text/xml"]);
$result = curl_exec($curl);
The result of this is giving me the token response as I expect
<?xml version="1.0" encoding="utf-8"?>
<S:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Header>
<wsa:Action S:mustUnderstand="1" wsu:Id="Action">http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue
</wsa:Action>
<wsa:To S:mustUnderstand="1" wsu:Id="To">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
</wsa:To>
<wsse:Security S:mustUnderstand="1">
<wsu:Timestamp wsu:Id="TS"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2018-10-10T13:44:01.2979816Z</wsu:Created>
<wsu:Expires>2018-10-10T13:49:01.2979816Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</S:Header>
<S:Body xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<wst:RequestSecurityTokenResponse
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wst:TokenType>urn:passport:compact</wst:TokenType>
<wsp:AppliesTo>
<wsa:EndpointReference xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>https://MYSHAREPOINTINSTANCE.sharepoint.com/</wsa:Address>
</wsa:EndpointReference>
</wsp:AppliesTo>
<wst:Lifetime>
<wsu:Created>2018-10-10T13:44:01Z</wsu:Created>
<wsu:Expires>2018-10-11T13:44:01Z</wsu:Expires>
</wst:Lifetime>
<wst:RequestedSecurityToken>
<wsse:BinarySecurityToken Id="Compact0"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
RETURNEDTOKEN
</wsse:BinarySecurityToken>
</wst:RequestedSecurityToken>
<wst:RequestedAttachedReference>
<wsse:SecurityTokenReference
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Reference URI="wmKM3OmbJLqPMfRK77SN0Isxyoc="></wsse:Reference>
</wsse:SecurityTokenReference>
</wst:RequestedAttachedReference>
<wst:RequestedUnattachedReference>
<wsse:SecurityTokenReference
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Reference URI="wmKM3OmbJLqPMfRK77SN0Isxyoc="></wsse:Reference>
</wsse:SecurityTokenReference>
</wst:RequestedUnattachedReference>
</wst:RequestSecurityTokenResponse>
</S:Body>
</S:Envelope>
Now I post that security token to login to Sharepoint
$curl = curl_init("https://MYSHAREPOINTINSTANCE.sharepoint.com/_forms/default.aspx?wa=wsignin1.0");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "RETURNEDTOKEN");
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-Type: text/plain"]);
$result = curl_exec($curl);
I get a 302 response however
<html><head><title>Object moved</title></head><body>\r\n
<h2>Object moved to here.</h2>\r\n ◀
</body></html>
If I include curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); in the request, or try to POST to the redirect URL directly, I am just returned HTML for a login screen and it's not actually doing anything with the security token in the post data that I'm sending.
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 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);
I have been working on a SOAP request / response using CURL with PHP, however I can't seem to work out how to extract the Data for the life of me.
Script for SOAP Request
$soapUrl = "https://xml.proveid.experian.com/IDSearch.cfc?wdsl";
// xml post structure
$xml_post_string = "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:cor='http://corpwsdl.oneninetwo'>
<soapenv:Header/>
<soapenv:Body>
<cor:search soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
<xml xsi:type='xsd:string'><![CDATA[
<Search xmlns:xsd='https://xml.proveid.experian.com/xsd/Search.xsd'>
<Authentication>
<Username>".$user."</Username>
<Password>".$pw."</Password>
</Authentication>
<CountryCode>GBR</CountryCode>
<Person>
<Name>
<Forename>".$firstName."</Forename>
<Surname>".$secondName."</Surname>
</Name>
<DateOfBirth>".$dob."</DateOfBirth>
</Person>
<Addresses>
<Address Current='1'>
<Premise>".$premise."</Premise>
<Street>".$streetName."</Street>
<PostTown>".$postTown."</PostTown>
<Region/>
<Postcode>".$postCode."</Postcode>
<CountryCode>GBR</CountryCode>
</Address>
</Addresses>
<Telephones>
<Telephone>
<Number>".$telephone."</Number>
</Telephone>
</Telephones>
<IPAddress>127.0.0.1</IPAddress>
<Emails>
<Email>".$email."</Email>
</Emails>
<SearchOptions>
<ProductCode>".$product."</ProductCode>
</SearchOptions>
</Search>]]>
</xml>
</cor:search>
</soapenv:Body>
</soapenv:Envelope>";
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: https://xml.proveid.experian.com/IDSearch.cfc",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
print_r($response);`
Response
<Search xmlns:xsd="https://xml.proveid.experian.com/xsd/Search.xsd">
<CountryCode>GBR</CountryCode>
<Person>
<Name><Forename>Baken</Forename>
<Surname>Jorure</Surname>
</Name>
<DateOfBirth>1989-09-09</DateOfBirth>
<Age>26</Age>
</Person>
<Addresses>
<Address Current="1">
<Premise>410</Premise>
<Street>Beuno Terrace</Street>
<PostTown>Beuno</PostTown>
<Region/>
<Postcode>LL545BT</Postcode>
<CountryCode>GBR</CountryCode>
</Address>
</Addresses>
<Telephones>
<Telephone>
<Number>01154567892</Number>
</Telephone>
</Telephones>
<IPAddress>127.0.0.1</IPAddress>
<Emails>
<Email>bakenjorure#www.com</Email>
</Emails>
<SearchOptions>
<ProductCode>ProveID</ProductCode>
</SearchOptions>
<OurReference>B3C369C0-F001-4FB1-80D3-801CB9D872FE</OurReference>
<SearchDate>2015-10-09T23:46:54</SearchDate>
<Result>
<Summary>
<ReportSummary>
<DatablocksSummary>
<DatablockSummary>
<Name>CreditReference</Name>
<Decision/>
</DatablockSummary>
</DatablocksSummary>
</ReportSummary>
<DecisionMatrix Code="ECIGSUAT" Name="Electronic Cigarettes">
<Decision>
<Outcome Type="Primary">0</Outcome>
<Reason>Individuals DOB has not matched to active CAIS
ER or Citizen Card therefore application has been
referred
</Reason>
</Decision>
</DecisionMatrix>
</Summary>
</Result>
</Search>
Now all I really need it the number in the Outcome tags. I've tried so many ways but I just can't seem to get it.
Any help would be much appreciated.
Thanks in advance.
For simplier usage of SOAP, you can use PHP builtin SOAP client.
http://php.net/manual/en/class.soapclient.php
With SoapClient class you could do something like this:
<?php
$soapUrl = "https://xml.proveid.experian.com/IDSearch.cfc?wdsl"
$soapClient = new SoapClient($soapUrl);
$parameters = array();
$result = $soapClient->Search($parameters);
?>
In result you will get native PHP data structure, not plain text XML as in here.
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