3
我試圖與在SOAP調用多個信封的xmlns命名空間SOAP調用,但我無法弄清楚如何正確地做到這一點...PHP - 使用多個的xmlns在信封與SoapClient的
下面的代碼我現在所擁有的:
$soapClient = new SoapClient(WSDL_URL, array(
"trace" => true,
"exceptions" => true
));
$soapClient->__setLocation(WSDL_LOCATION);
$request = '
<ns1:someNodeName xmlns="http://some.webservice.url.com">
<ns2:someOtherNodeName>
// [REQUEST DETAILS]
</ns2:someOtherNodeName>
</ns1:someNodeName>
';
$params = new SoapVar($request, XSD_ANYXML);
try {
$results = $soapClient->someFunctionName($params);
return $results;
}
catch (Exception $e) {
$error_xml = $soapClient->__getLastRequest();
echo $error_xml . "\n";
echo $e->getMessage() . "\n";
}
此代碼給了我像一個XML請求如下:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://some.webservice.url.com">
<SOAP-ENV:Body>
<ns1:someNodeName xmlns="http://some.webservice.url.com">
<ns2:someOtherNodeName>
// [REQUEST DETAILS]
</ns2:someOtherNodeName>
</ns1:someNodeName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我試圖改變的是包絡線,要達到這樣的:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://some.webservice.url.com"
xmlns:ns2="http://some.other.webservice.url.com"
>
請問有什麼辦法可以實現這個嗎?
謝謝了很多。像魅力一樣工作! –