实际上,我创建了一个 Soap 代理,在其中我获取客户端请求,并且需要将请求进一步发布到另一个 SOAP 服务器(使用 c_url)。
成功获得响应(作为 xml<SOAP-ENV
和所有其他)。
问题是,在我的 SOAP 代理中,我想准确地返回响应,如果我的服务器正在返回 xml,那么 SOAP 服务器实际上会返回 XML 文件包装
<SOAP-ENV:Envelope ...>
<SOAP-ENV:Body>
<ns1:loginResponse>
my xml that already contains <soap:Envelope, <soap:Body> and <namesp1:loginResponse>
</ns1:loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
问题是:我怎样才能让肥皂服务器准确地返回我想要的响应,而不用用肥皂信封和其他东西包装起来?
谢谢。
更新:
我的肥皂服务器:
$server = new SoapServer($myOwnWsdlPath);
$this->load->library('SoapProxy');
$server->setClass('SoapProxy', $params );
$server->handle();
我的带有 c_url 的肥皂 Porxy:
public function __call($actionName, $inputArgs)
{
//some logic
$target = ...
$url = ..
$soapBody =..
$headers = ..
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soapBody); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch); //soap xml response
curl_close($ch);
file_put_contents('/tmp/SoapCurl.txt', var_export($response, true));
return $response;
}
/tmp/SoapCurl.txt 的响应是正确的:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope ...>
<soap:Body>
<namesp1:loginResponse>
<session_id xsi:type="xsd:string">data</session_id>
</namesp1:loginResponse>
</soap:Body>
</soap:Envelope>
我的肥皂服务器响应是错误的:
<SOAP-ENV:Envelope ...>
<SOAP-ENV:Body>
<ns1:loginResponse>
<soap:Envelope ...>
<soap:Body>
<namesp1:loginResponse>
<session_id xsi:type="xsd:string">correct data</session_id>
</namesp1:loginResponse>
</soap:Body>
</soap:Envelope>
</ns1:loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>