开发者

complex SOAP message using wsd2php produced file

Greetings stackoverflow.

I have been tinkering about with a SOAP client using PHP5's native extension. The SOAP message I am trying to create, uses complex Data Types.

So far I have created a class file using the wsdl2php tool (http://www.urdalen.no/wsdl2php/). I have successfully created parts of my SOAP message however, I am sure I am doing this incorrectly. Please see below:

The message I want to create:

<soap:Envelope>
 <soap:Body>
  <OTA_HotelAvailRQ Version="1.0" AvailRatesOnly="true" TimeStamp="2010-10-06T16:14:26+08:00">
   <POS>
    <Source>
     <RequestorID ID="test" Type="10"/>
    </Source>
   </POS>
   <AvailRequestSegments>
    <AvailRequestSegment AvailReqType="NonRoom">
     <HotelSearchCriteria AvailableOnlyIndica开发者_C百科tor="1">
      <Criterion>
       <HotelRef HotelCode="PCBCMS"/>
       <StayDateRange Start="2010-10-06" End="2010-11-06"/>
      </Criterion>
     </HotelSearchCriteria>
    </AvailRequestSegment>
   </AvailRequestSegments>
  </OTA_HotelAvailRQ>
 </soap:Body>
</soap:Envelope>

With the following code I am able to produce part of the message however when it comes to:

// Hotel Availability
$qOTAhrq = new OTA_HotelAvailRQ();

$qOTAhrq->AvailRequestSegments['AvailRequestSegment'] = array('AvailReqType' => 'NonRoom');
$qOTAhrq->AvailRequestSegments['AvailRequestSegment']['HotelSearchCriteria'] = array();
$qOTAhrq->AvailRequestSegments['AvailRequestSegment']['HotelSearchCriteria']['Criterion'] = array();

The following message is produced by the code above. Whats going wrong :(

<ns1:AvailRequestSegments>
 <ns1:AvailRequestSegment AvailReqType="NonRoom">
   <ns1:HotelSearchCriteria/>
 </ns1:AvailRequestSegment>
</ns1:AvailRequestSegments>

needs to be


<ns1:AvailRequestSegments>
 <ns1:AvailRequestSegment AvailReqType="NonRoom">
   <ns1:HotelSearchCriteria AvailOnlyIndicator="1"/>
 </ns1:AvailRequestSegment>
</ns1:AvailRequestSegments>

Hopefully my question is extensive enough to understand what I am trying to achieve. Am I using the correct method to produce my xml soap message or should I not be using arrays this way? Is there a way where i can type something like:

$qOTAhrq->AvailRequestSegments->AvailRequestSegment = array('AvailReqType='nonRoom');

links: my classfile: wsdl class file (created by wsdl2php)

please help - perhaps my message will help someone else in the future :)


I am not fully sure, but I don't seem to find any code segment that would evaluate to:<ns1:HotelSearchCriteria AvailOnlyIndicator="1"/> Perhaps you want something like,

$qOTAhrq->AvailRequestSegments['AvailRequestSegment']['HotelSearchCriteria'] = array("AvailOnlyIndicator"=>"1");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜