Hearaman
Hearaman

Reputation: 8726

how to send xml request using soap in php?

I am working on new project, for this project i have to use SOAP. I am new to this SOAP. I red my project documentation. In that documentation it has WSDL and XML request. By using boath WSDL and XML request how can i send XML request. Bellow i am writing WSDL and XML request. Please help me.

Thankyou.


WSDL:

http://acceptance.travelstreet.com/hotelsv3/components/hotels_ws.cfc?wsdl

XML REQUEST:

<?xml version="1.0" encoding="utf-8"?>
<OTA_HotelAvailRQ Version="1.0">
   <POS>
    <Source>
     <UniqueId Id="username:password" />
    </Source>
   </POS>
   <AvailRequestSegments>
    <AvailRequestSegment>
     <StayDateRange End="2011-08-15" Start="2011-08-14" />
     <RoomStayCandidates>
      <RoomStayCandidate Quantity="1">
       <GuestCounts>
        <GuestCount AgeQualifyingCode="10" Count="1" />
       </GuestCounts>
      </RoomStayCandidate>
     </RoomStayCandidates>
     <HotelSearchCriteria>
      <Criterion>
       <HotelRef Destination="East London, South Africa" CityCode="" CountryCode="" HotelName="" MinHotelRating="1"/>
       <SearchCurrency>EUR</SearchCurrency>
       <AdditionalInfo Value="1" />
       <Language>EN</Language>
      </Criterion>
     </HotelSearchCriteria>
    </AvailRequestSegment>
   </AvailRequestSegments>
  </OTA_HotelAvailRQ>

Upvotes: 4

Views: 30227

Answers (2)

Marin Vartan
Marin Vartan

Reputation: 582

For attributes, you must call SoapVar with XSD_ANYXML http://php.net

Upvotes: 1

Spudley
Spudley

Reputation: 168645

I suggest you read up about PHP's SoapClient. There are lots of good examples in the PHP manual.

To get you started, create the object:

$client = new SoapClient('http://www.example.com/end_point.wsdl');

Then call the method:

$result = $client->SomeFunction($data);

where SomeFunction is the method name you want to call on the service, and $data is a PHP array representing the XML data structure you want to send.

Hope that helps.

[EDIT] Just to clarify in light of the OP's further questions:

You don't need to create the actual XML code when using PHP SOAPClient. You need to put the data into a PHP array, and SOAPClient will convert it to XML for you. The array keys should be named for the XML element names, and the array values are the element values. Use nested arrays for nested XML elements.

Upvotes: 10

Related Questions