我正在尝试使用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>';
我收到此错误
Fatal error: Uncaught SoapFault exception: [soapenv:Client.2000] Mandatory values missing in the Message Header...
如果此方法有误,如何为上述XML请求创建soap标头和正文?
答案 0 :(得分:0)
这个问题很难回答,因为它缺乏必要的文档和参数来测试一个例子。它似乎也是一种需要帐户的付费商业服务。
因此,我们可以做的最好的事情就是演示如何在同一网站上使用更简单的服务。这个不需要任何参数并返回版本,如下所示。
可以使用其他服务列表here。
public class AccountsController : Controller
{
[Route("[controller]/welcome")]
public IActionResult DoSomething()
{
return View();
}
}
Web服务返回:
$output = "<div id=\"sliding\" class=\"flexslider flexslider--post-content\">\n";
[...]
$output = "<div id=\"carousel\" class=\"flexslider flexslider--post-content-carousel\">\n";