这是我的脚本的开头:
<?php
$soapUrl = 'http://webservicetocall.com/Interface/ChannelConnect.asmx?WSDL';
$client = new SoapClient($soapUrl);
$headerBody = array(
'From' => array(
'Credential' => array(
'userName' => 'MYUSERNAME',
'password' => 'MYPASSWORD',
)
),
);
$params = array(
'OTA_HotelAvailRQ' => array(
'BestOnly' => 'false',
'SummaryOnly' => 'false',
'HotelStayOnly' => 'true',
'MaxResponses' => 0,
'ExactMatchOnly' => 'true',
'POS' => array(
'Source' => array(
'Requestor' => array(
'ID_Context' => 'Synxis',
'ID' => '10',
'CompanyName' => array(
'Code' => 'AAAA',
),
),
),
),
'AvailableRequestSegements' => array(
'AvailableRequestSegment' => array(
'AvailReqType' => 'Room',
'StayDateRange' => array(
'Start' => '05/10/2015',
'End' => '05/17/2015',
),
'RoomStayCandidate' => array(
'Quantity' => '1',
'GuestCounts' => array(
'GuestCount' => array(
'AgeQualifyingCode' => '10',
'Count' => '1',
),
),
),
'HotelSearchCriteria' => array(
'Criterion' => array(
'HotelRef' => array(
'HotelCode' => '12345',
),
),
),
),
),
),
);
$ns = 'http://htng.org/1.1/Header/';
$client = new SoapClient($soapUrl, array(
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
)
);
$header = new SOAPHeader($ns, 'HTNGHeader', $headerBody);
$client->__setSoapHeaders($header);
$hotel_info = $client->__soapCall('CheckAvailability', $params);
$last_call = $client->__getLastRequest();
以下是$ client-&gt; __ getLastRequest()返回的内容。
我不太明白为什么我的整个数组都没有作为正文的一部分传递。有任何想法吗?这是我第一次使用SoapClient类的经历,我无法找到有关如何正确使用它的任何好的解释。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.opentravel.org/OTA/2003/05" xmlns:ns2="http://htng.org/1.1/Header/">
<SOAP-ENV:Header>
<ns2:HTNGHeader>
<ns2:From>
<ns2:Credential>
<ns2:userName>MYUSERNAME</ns2:userName>
<ns2:password>MYPASSWORD</ns2:password>
</ns2:Credential>
</ns2:From>
</ns2:HTNGHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:OTA_HotelAvailRQ BestOnly="true" ExactMatchOnly="true" HotelStayOnly="true" MaxResponses="0" SummaryOnly="true">
<ns1:POS>
<ns1:Source/>
</ns1:POS>
</ns1:OTA_HotelAvailRQ>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>