I have to create the following XML request using SOAP:
<SimpleRequest>
<MessageHeader SegmentId="MSGHDR">
<MessageId>CCREQ1</MessageId>
<SessionId>12345</SessionId>
<ReqCode>PL</ReqCode>
<UserName>USA123</UserName>
<AgencyId>5588</AgencyId>
<UICode>5</UICode>
</MessageHeader>
<RoomAvailabilityRequest SegmentId="REQ1">
<RoomId>A14</RoomId>
<Date>05112016</Date>
<DurationDays></DurationDays>
<Embark Code="SFO"/>
<Debark Code="EWR"/>
<Transport Code="CA"/>
<City Code="EWR"/>
<Currency Code="USD"/>
</RoomAvailabilityRequest>
</SimpleRequest>
I have tried the following but it keeps failing:
<?php
$url = "http://ift.tt/1FrStMj";
$client = new SoapClient(null, array(
'location' => $url,
'uri' => $url,
"trace" => 1,
"exceptions" => 0));
$xml = '<RoomAvailabilityRequest SegmentId="REQ1">
<RoomId>A14</RoomId>
<Date>05112016</Date>
<DurationDays></DurationDays>
<Embark Code="SFO"/>
<Debark Code="EWR"/>
<Transport Code="CA"/>
<City Code="EWR"/>
<Currency Code="USD"/>
</RoomAvailabilityRequest>';
$params = new SoapVar($xml, XSD_ANYXML);
$arr = array(
$params
);
$xml_header_string = '<MessageHeader SegmentId="MSGHDR">
<MessageId>CCREQ1</MessageId>
<SessionId>12345</SessionId>
<ReqCode>PL</ReqCode>
<UserName>USA123</UserName>
<AgencyId>5588</AgencyId>
<UICode>5</UICode>
</MessageHeader>';
$xml_header = new SoapVar($xml_header_string, XSD_ANYXML);
$header = new SoapHeader('http://ift.tt/1C5pQFZ',
"MessageHeader",
$xml_header);
$value = $client->__soapCall("SimpleRequest", $arr, null, $header);
print "<pre>\n";
print "<br />\n Request : " . htmlspecialchars($client->__getLastRequest());
print "<br />\n Response: " . htmlspecialchars($client->__getLastResponse());
print "</pre>";
This is what the PHP produces as a request:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:ns1="http://ift.tt/1FrStMj" xmlns:ns2="http://ift.tt/1C5pQFZ" xmlns:xsd="http://ift.tt/tphNwY" xmlns:SOAP-ENC="http://ift.tt/wEYywg" SOAP-ENV:encodingStyle="http://ift.tt/wEYywg">
<SOAP-ENV:Header>
<MessageHeader SegmentId="MSGHDR">
<MessageId>CCREQ1</MessageId>
<SessionId>12345</SessionId>
<ReqCode>PL</ReqCode>
<UserName>USA123</UserName>
<AgencyId>5588</AgencyId>
<UICode>5</UICode>
</MessageHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:SimpleRequest>
<RoomAvailabilityRequest SegmentId="REQ1">
<RoomId>A14</RoomId>
<Date>05112016</Date>
<DurationDays></DurationDays>
<Embark Code="SFO"/>
<Debark Code="EWR"/>
<Transport Code="CA"/>
<City Code="EWR"/>
<Currency Code="USD"/>
</RoomAvailabilityRequest>
</ns1:SimpleRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Please help me create this XML needed. Let me know if any more information is required. Thank you in advance.
No comments:
Post a Comment