关于PHP和SOAP的问题很多.但我没有找到答案我的情况.
所以.我使用PHP SoapClient和WSDL.对象发送此:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.site.com"><SOAP-ENV:Body>
Run Code Online (Sandbox Code Playgroud)
但我需要这个:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body>
Run Code Online (Sandbox Code Playgroud)
题.我如何使用标准的PHP类SoapClient来做到这一点?
谢谢.
我在php.net中搜索答案
<?php
class MSSoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
$namespace = "http://tempuri.com";
$request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$namespace.'"', $request, 1);
$request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
$request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);
// parent call
return parent::__doRequest($request, $location, $action, $version);
}
}
$client = new MSSoapClient(...);
?>
Run Code Online (Sandbox Code Playgroud)
此代码在请求中更改Envelope.并且需要ASP SOAP服务器.