Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP SoapClient创建原始XML请求_Php_Soap_Wsdl_Soap Client - Fatal编程技术网

使用PHP SoapClient创建原始XML请求

使用PHP SoapClient创建原始XML请求,php,soap,wsdl,soap-client,Php,Soap,Wsdl,Soap Client,我正在尝试使用SoapVar创建原始XML请求。这是我的密码 #- Loading the WSDL document $wsdl = "https://ota2-p1.ihotelier.com/OTA_Seamless/services/DailyRateService?wsdl"; $client = new SoapClient($wsdl,array('trace' => true, 'exceptions' => true)); #- Cre

我正在尝试使用SoapVar创建原始XML请求。这是我的密码

#- 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>';
遵循教程。我做错了什么


如果此方法错误,如何为上述XML请求创建soap头和体?

此问题很难回答,因为它缺少测试示例所需的文档和参数。它似乎也是一种需要账户的付费商业服务

因此,也许我们能做的最好的事情就是演示如何从同一个站点使用更简单的服务。这个不需要任何参数,并返回如下所示的版本

还提供了其他服务的列表


谢谢罗伯托。我们已经要求客户提供所需的参数。嗨,我从客户那里得到了所需的值。不过,我还是遇到了同样的错误,即消息头中缺少
强制值
,我遵循了这个答案,它运行良好
http://stackoverflow.com/a/17053242/1409399
Fatal error: Uncaught SoapFault exception: [soapenv:Client.2000] Mandatory values missing in the Message Header...
<?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();
   }
?> 
Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)