我必须发出一个SOAP请求,但是由于使用SoapClient我无法获得假定的XML,因此我遇到了一些问题。
这是正确的xml请求
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header>
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>10983</wsse:Username>
<wsse:Password>test2019</wsse:Password>
<Context>10000Hoteis</Context>
</wsse:Security>
</soap-env:Header>
<soap-env:Body>
<OTA_ReadRQ xmlns:ns="http://www.opentravel.org/OTA/2003/05/common"
xmlns="http://www.opentravel.org/OTA/2003/05" TimeStamp="2015-07-16T06:38:10.60">
<ReadRequests>
<HotelReadRequest>
<TPA_Extensions>
<RequestType>GetCities</RequestType>
<CountryCode>PT</CountryCode>
</TPA_Extensions>
</HotelReadRequest>
</ReadRequests>
</OTA_ReadRQ>
</soap-env:Body>
</soap-env:Envelope>
这是我当前的php代码
$xmlheader = <<<XML
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>myusername</wsse:Username>
<wsse:Password>mypassword</wsse:Password>
<Context>10000Hoteis</Context>
</wsse:Security>
XML;
$xmlbody = <<<XML
<OTA_ReadRQ xmlns:ns="http://www.opentravel.org/OTA/2003/05/common"
xmlns="http://www.opentravel.org/OTA/2003/05" TimeStamp="2015-07-16T06:38:10.60">
<ReadRequests>
<HotelReadRequest>
<TPA_Extensions>
<RequestType>GetCities</RequestType>
<CountryCode>PT</CountryCode>
</TPA_Extensions>
</HotelReadRequest>
</ReadRequests>
</OTA_ReadRQ>
XML;
$headerXML = new \SoapVar($xmlheader,XSD_ANYXML);
$body = new \SoapVar($xmlbody,XSD_ANYXML);
$client = new \SoapClient(null, ['location' => 'http://10000hoteis.com.pt/NewAvailabilityServlet/staticdata/OTA2014A', 'uri' =>'http://schemas.xmlsoap.org/soap/envelope/' ,'trace' => true]);
$header = new \SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $headerXML);
$client->__setSoapHeaders($header);
$result = $client->OTA_ReadRQ($body);
但这不起作用,因为多了一个
<SOAP-ENV:OTA_ReadRQ>
在body标签和
之间<OTA_ReadRQ xmlns:ns="http://www.opentravel.org/OTA/2003/05/common"
xmlns="http://www.opentravel.org/OTA/2003/05" TimeStamp="2015-07-16T06:38:10.60">
如何正确执行此请求?