0

I am trying to create raw XML request with SoapVar. Here is my code

#- Loading the WSDL document
  $wsdl = "https://ota2-p1.ihotelier.com/OTA_Seamless/services/DailyRateService?wsdl";
  $client = new SoapClient($wsdl,array('trace' => true, 'exceptions' => true));

#- Creating the XML document
   $xml = <<<EOT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ota="http://services.ota.travelclick.com">
<soap:Header>
   <wsa:MessageID>86830</wsa:MessageID>
   <wsa:ReplyTo>
      <wsa:Address>NOT NEEDED FOR SYNC REQUEST</wsa:Address>
   </wsa:ReplyTo>
   <wsa:To>https://ota2-p1.ihotelier.com/OTA_Seamless/services/DailyRateService</wsa:To>
   <wsa:Action>DailyRate</wsa:Action>
   <wsa:From>
      <SalesChannelInfo ID="XXXXXXXXX"/><!-- Fields to be provided by TC -->
   </wsa:From>
   <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
      <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsu:Created>2016-02-05T15:55:56+00:00</wsu:Created>
         <wsu:Expires>2016-02-06T15:56:06+00:00</wsu:Expires>
      </wsu:Timestamp>
      <wsse:UsernameToken>
         <wsse:Username>XXXXX</wsse:Username><!-- Fields to be provided by TC -->
         <wsse:Password>XXXXXX</wsse:Password><!-- Fields to be provided by TC -->
      </wsse:UsernameToken>
   </wsse:Security>
</soap:Header>

<soap:Body>
<OTA_HotelAvailRQ Version="2.0" AvailRatesOnly="False" TimeStamp="2016-02-05T15:55:56+00:00">
   <POS>
      <Source>
         <RequestorID Type="1" ID="" MessagePassword=""/><!-- Fields to be provided by TC -->
         <BookingChannel Type="18">
            <CompanyName CompanyShortName="" Code=""/><!-- Fields to be provided by TC -->
         </BookingChannel>
      </Source>
   </POS>
   <AvailRequestSegments>
      <AvailRequestSegment ResponseType="DailyRateList"><!-- request type -->
         <HotelSearchCriteria AvailableOnlyIndicator="false">
            <Criterion>
               <HotelRef HotelCode="97593"/><!-- iHotelierID -->
               <StayDateRange Start="2016-02-08" End="2016-02-15"/>
               <RoomStayCandidates>
                  <RoomStayCandidate Quantity="1">
                     <GuestCounts>
                        <GuestCount AgeQualifyingCode="10" Count="1"/><!-- Adult -->
                        <GuestCount AgeQualifyingCode="8" Count="0"/><!-- Child -->
                        <GuestCount AgeQualifyingCode="7" Count="0"/><!-- Infant -->
                     </GuestCounts>
                  </RoomStayCandidate>
               </RoomStayCandidates>
            </Criterion>
         </HotelSearchCriteria>
      </AvailRequestSegment>
   </AvailRequestSegments>
</OTA_HotelAvailRQ>
</soap:Body></soap:Envelope>
EOT;

   $body = new SoapVar($xml,XSD_ANYXML);

#- Calling the service method
   $result = $client->serviceRequest($body);


#- Showing the request and response
   echo '<pre>', htmlentities($client->__getLastRequest()), '</pre>';
   echo "<br> --------response---------<br>";
   echo '<pre>', htmlentities($client->__getLastResponse()), '</pre>';

and i'm getting this error

Fatal error: Uncaught SoapFault exception: [soapenv:Client.2000] Mandatory values missing in the Message Header...

Followed this tutorial. What I'm doing wrong?

If this method is wrong, how do I create soap header and body for the above XML request?

Community
  • 1
  • 1
iLaYa ツ
  • 3,941
  • 3
  • 32
  • 48

1 Answers1

0

This question is difficult to answer because it lacks necessary documentation and parameters to test an example. It also appears to be a paid commercial service that requires an account.

So perhaps the best we can do is demonstrate how to use a much more simple service from the same site. This one does not require any parameters and returns the version as shown below.

A list of other services is available here.

<?php 
    try {
        $client = new SoapClient('https://ota2-p1.ihotelier.com/OTA_Seamless/services/Version?wsdl');
        $result = $client->getVersion( );
        print_r($result);
   }
   catch(Exception $e) {
       echo "\nException:" .$e->getMessage();
   }
?> 

Web Service Returns:

Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT) 
Yogi
  • 6,241
  • 3
  • 24
  • 30