我的SOAP请求无法正常工作,并且被托管公司要求更改请求XML的格式。
当前,我的XML请求如下:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:Search>
<ns1:Header>
<ns1:AgentId>333</ns1:AgentId>
</ns1:Header>
<ns1:Search>
<ns1:CityId>234</ns1:CityId>
<ns1:HotelId>2209714</ns1:HotelId>
<ns1:SearchRooms>
<ns1:SearchRoom>
<ns1:Adult>2</ns1:Adult>
</ns1:SearchRoom>
</ns1:SearchRooms>
<ns1:PaxCountryId>25</ns1:PaxCountryId>
</ns1:Search>
</ns1:Search>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但是主持人公司要求它看起来像这样...
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<Search xmlns="http://tempuri.org/">
<Header>
<AgentId>333</AgentId>
</Header>
<Search>
<CityId>234</CityId>
<HotelId>2209714</HotelId>
<SearchRooms>
<SearchRoom>
<Adult>2</Adult>
</SearchRoom>
</SearchRooms>
<PaxCountryId>25</PaxCountryId>
</Search>
</Search>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我的PHP请求:
try {
$data = array("Search" =>
array(
"Header" => array(
"AgentId" => "333",
),
"Search" => array(
"CityId" => "234",
"HotelId" => "2209714",
"SearchRooms" => array(
"SearchRoom" => array(
"Adult" => "2",
),
)
),
)
);
$client = new SoapClient('xxxxx', array('trace'=> 1));
$retour_ws = $client -> __call('Search',$data);
echo htmlspecialchars($client->__getLastRequest());
echo htmlspecialchars($client->__getLastResponse());
}
catch (Exception $e) {
echo $e;
}
有人可以帮助我找到在没有名称空间ns1的情况下更改输出XML格式的要求吗?