如何使用postman和php发送soap 4.0标头

问题描述 投票:0回答:2

我想使用 Amadeus API 进行搜索航班。 我购买了企业帐户。 他们向我提供了凭据。 但也许我的请求没有达到他们的终点。 我正在尝试通过邮递员。 但当我们在浏览器上打开时,会返回相同的响应。 即我的请求参数没有命中 URL:

这是我的代码


$soapUrl = "https://noded2.test.webservices.amadeus.com/".$wsap;
/*
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/"><customerID>XXX</customerID><key>XXXXXX-XXXXXX</key><serviceID></serviceID><paramID>0</paramID><address>RiksvŠgen 5</address><postcode>59018</postcode><city>Mantorp</city><maxhits>10</maxhits></SearchCollectionPoint></soap12:Body></soap12:Envelope>';
*/
$xml_post_string  = '';
$xml_post_string .= '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ses="http://xml.amadeus.com/2010/06/Session_v3">';
$xml_post_string .= '<soap:Header>';
// $xml_post_string .= '<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">2fc42c4e-d34f-414e-b064-d37acd6bdc9c</add:MessageID>';
$xml_post_string .= '<add:MessageID xmlns:add="http://www.w3.org/2005/08/addressing">'.$MessageID.'</add:MessageID>';
$xml_post_string .= '<add:Action xmlns:add="http://www.w3.org/2005/08/addressing">http://webservices.amadeus.com/FMPTBQ_18_1_1A</add:Action>';
$xml_post_string .= '<add:To xmlns:add="http://www.w3.org/2005/08/addressing">https://noded2.test.webservices.amadeus.com/'.$wsap.'</add:To>';
$xml_post_string .= '<link:TransactionFlowLink xmlns:link="http://wsdl.amadeus.com/2010/06/ws/Link_v1" />';
$xml_post_string .= '<oas:Security xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:oas1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
$xml_post_string .= '<oas:UsernameToken oas1:Id="UsernameToken-1">';
$xml_post_string .= '<oas:Username>'.$wbs_user_id.'</oas:Username>';
$xml_post_string .= '<oas:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'.$nonce.'</oas:Nonce>';
$xml_post_string .= '<oas:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">'.$passworddigest.'</oas:Password>';
$xml_post_string .= '<oas1:Created>'.$created.'</oas1:Created>';
$xml_post_string .= '</oas:UsernameToken>';
$xml_post_string .= '</oas:Security>';
$xml_post_string .= '<AMA_SecurityHostedUser xmlns="http://xml.amadeus.com/2010/06/Security_v1">';
$xml_post_string .= '<UserID AgentDutyCode="SU" POS_Type="1" PseudoCityCode="'.$office_id.'" RequestorType="U" />';
$xml_post_string .= '</AMA_SecurityHostedUser>';
$xml_post_string .= '</soap:Header>';
$xml_post_string .= '<soap:Body>';
$xml_post_string .= '<Fare_MasterPricerTravelBoardSearch>';
$xml_post_string .= '<numberOfUnit>';
$xml_post_string .= '<unitNumberDetail>';
$xml_post_string .= '<numberOfUnits>30</numberOfUnits>';
$xml_post_string .= '<typeOfUnit>RC</typeOfUnit>';
$xml_post_string .= '</unitNumberDetail>';
$xml_post_string .= '<unitNumberDetail>';
$xml_post_string .= '<numberOfUnits>1</numberOfUnits>';
$xml_post_string .= '<typeOfUnit>PX</typeOfUnit>';
$xml_post_string .= '</unitNumberDetail>';
$xml_post_string .= '</numberOfUnit>';
$xml_post_string .= '<paxReference>';
$xml_post_string .= '<ptc>ADT</ptc>';
$xml_post_string .= '<traveller>';
$xml_post_string .= '<ref>1</ref>';
$xml_post_string .= '</traveller>';
$xml_post_string .= '</paxReference>';
$xml_post_string .= '<fareOptions>';
$xml_post_string .= '<pricingTickInfo>';
$xml_post_string .= '<pricingTicketing>';
$xml_post_string .= '<priceType>ET</priceType>';
$xml_post_string .= '<priceType>RP</priceType>';
$xml_post_string .= '<priceType>RU</priceType>';
$xml_post_string .= '</pricingTicketing>';
$xml_post_string .= '</pricingTickInfo>';
$xml_post_string .= '</fareOptions>';
$xml_post_string .= '<travelFlightInfo />';
$xml_post_string .= '<itinerary>';
$xml_post_string .= '<requestedSegmentRef>';
$xml_post_string .= '<segRef>1</segRef>';
$xml_post_string .= '</requestedSegmentRef>';
$xml_post_string .= '<departureLocalization>';
$xml_post_string .= '<departurePoint>';
$xml_post_string .= '<locationId>NYC</locationId>';
$xml_post_string .= '</departurePoint>';
$xml_post_string .= '</departureLocalization>';
$xml_post_string .= '<arrivalLocalization>';
$xml_post_string .= '<arrivalPointDetails>';
$xml_post_string .= '<locationId>MIA</locationId>';
$xml_post_string .= '</arrivalPointDetails>';
$xml_post_string .= '</arrivalLocalization>';
$xml_post_string .= '<timeDetails>';
$xml_post_string .= '<firstDateTimeDetail>';
$xml_post_string .= '<date>171219</date>';
$xml_post_string .= '</firstDateTimeDetail>';
$xml_post_string .= '</timeDetails>';
$xml_post_string .= '</itinerary>';
$xml_post_string .= '</Fare_MasterPricerTravelBoardSearch>';
$xml_post_string .= '</soap:Body>';
$xml_post_string .= '</soap:Envelope>';

header('Content-Type: text/xml');
// echo $xml_post_string;

$headers = array(
"POST ".$wsap." HTTP/1.1",
"Host: noded2.test.webservices.amadeus.com",
"Content-Type: application/soap+xml; charset=utf-8",
"Content-Length: ".strlen($xml_post_string)
); 

$url = $soapUrl;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch); 
curl_close($ch);

php soap postman soapheader amadeus
2个回答
0
投票

只需将

<add:Action>
元素中的值添加到“SOAPAction”标头即可。


0
投票

我也面临着同样的问题。可以分享一下邮递员的收藏吗?还是完整的请求? @varad_s

© www.soinside.com 2019 - 2024. All rights reserved.