【发布时间】:2015-10-19 07:58:34
【问题描述】:
我正在尝试在 SOAP 调用信封中使用多个 xmlns 命名空间进行 SOAP 调用,但我不知道如何正确执行此操作...
这是我现在拥有的代码:
$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"
>
请问有什么方法可以实现吗?
【问题讨论】:
标签: php xml soap namespaces soap-client