我需要从WSDL项目发出一个Soap请求,并且需要在请求中发送 <soapenv:envelope>
。
我没有找到任何说明如何执行此操作的帖子。
我的一个朋友使用了下面的代码,所以我尝试了一下,但是对我没有用。
有人知道如何在 SoapClient 中发送 <soapenv:envelope>
吗?
任何帮助将不胜感激
$wsdl_url = 'http:/endpoint/to/wsdl/project?wsdl';
$credentials = [
'login' => 'login',
'password' => 'password',
'trace' => true,
];
$client = new SoapClient_WorkAround($wsdl_url, $credentials);
这是我从 SoapClient
扩展的类class SoapClient_WorkAround extends \SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way=0)
{
$request = '<soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wss="http://www.adonix.com/WSS">
<soapenv:Header/>
<soapenv:Body>
<wss:run soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<callContext xsi:type="wss:CAdxCallContext">
<codeLang xsi:type="xsd:string">codeLang</codeLang>
<poolAlias xsi:type="xsd:string">poolAlias</poolAlias>
<poolId xsi:type="xsd:string">poolId</poolId>
<requestConfig xsi:type="xsd:string">adxwss.beautify=true</requestConfig>
</callContext>
<publicName xsi:type="xsd:string">publicName</publicName>
<inputXml xsi:type="xsd:string">
<![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<PARAM>
<FLD NAME="P_LOGIN">login</FLD>
</PARAM>
]]>
</inputXml>
</wss:run>
</soapenv:Body>
</soapenv:Envelope>';
return parent::__doRequest($request, $location, $action, $version, $one_way);
}
}
谢谢!