4

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>
1
  • What is your exact question? Have you read the manual about SOAP on php.net? Commented Jun 30, 2011 at 13:22

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

8 Comments

Tahnks. i have done according to you. But it gave "Internal Server Error". How to solve this. My request is working properly on Netbease SOAP UI.
@Hearaman - Inernal Server error suggests that you have a syntax error in your PHP. I suggest you turn error reporting on or look at the server logs to find out what the error is.
<?php $xml='<?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>'; try { $soap = new SoapClient("acceptance.travelstreet.com/hotelsv3/components/…> true, 'exceptions' => true)); $res=$soap->__call("OTA_HotelAvailRQ", array($xml)); }
catch(SoapFault $fault) { echo $fault->getMessage(); } ?>
|
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.