這是我需要發送的SOAP請求,它在SOAP UI程序中完美工作並返回有效的響應。有人可以請解釋如何通過PHP創建這個複雜的SOAP請求?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.escapia.com/EVRN/2007/02">
<soapenv:Body>
<ns:EVRN_UnitDescriptiveInfoRQ Target="Production" Version="1.0">
<ns:POS>
<ns:Source>
<ns:RequestorID ID="username" MessagePassword="password"/>
</ns:Source>
</ns:POS>
<ns:UnitDescriptiveInfos>
<ns:UnitDescriptiveInfo/>
</ns:UnitDescriptiveInfos>
</ns:EVRN_UnitDescriptiveInfoRQ>
</soapenv:Body>
</soapenv:Envelope>
以下是我在PHP已經試過......
$wsdl = 'https://api.escapia.com/EVRNContentService.svc?wsdl';
$options = array(
'trace' => false
);
$client = new \SoapClient($wsdl, $options);
$xmlr = new SimpleXMLElement('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.escapia.com/EVRN/2007/02">
<soapenv:Body>
<ns:EVRN_UnitDescriptiveInfoRQ Target="Production" Version="1.0">
<ns:POS>
<ns:Source>
<ns:RequestorID ID="username" MessagePassword="password"/>
</ns:Source>
</ns:POS>
<ns:UnitDescriptiveInfos>
<ns:UnitDescriptiveInfo/>
</ns:UnitDescriptiveInfos>
</ns:EVRN_UnitDescriptiveInfoRQ>
</soapenv:Body>
</soapenv:Envelope>');
$params = new SoapVar($xmlr, XSD_STRING);
try {
$response = $client->UnitDescriptiveInfoStream($params);
echo '<pre>';
var_dump($response);
echo '</pre>';
} catch (SoapFault $e) {
echo '<pre>';
var_dump($client);
echo '</pre>';
}
然而,這只是返回的響應..
object(stdClass)#4 (1) {
["any"]=>
string(388) "Failed to authenticate anonymous client. Source array is missing from request."
}
請如果任何人有任何想法如何通過PHP正確地提出這個請求,那將是令人愉快的。
您是否嘗試過通過捲曲這樣做呢? – Rimble
如果您不使用'soapui',它可以從標籤中刪除。 – Rao