【发布时间】:2013-08-29 10:23:16
【问题描述】:
实际上,我创建了一个 Soap 代理,在其中我获取客户端请求,我需要将请求进一步发布到另一个 SOAP 服务器(使用 c_url)。
成功获得响应(作为带有<SOAP-ENV 和所有其他的xml)。
问题在于,在我的 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>
问题是:我怎样才能让soap服务器准确地返回我想要的响应而不用soap信封和其他东西包装起来?
谢谢。
更新:
我的肥皂服务器:
$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>
【问题讨论】:
-
那么是什么阻止你这样做呢?让我感到困惑的是:这实际上与 SOAP 相关还是只是传递 HTTP 请求(代理它)?
-
客户端向我的 SOAP SERVER 发出一个肥皂请求,我向另一个 SOAP SERVER 发出同样的请求,这个 XML 响应应该被发送回我的客户端。
-
是的,我的问题是,是什么阻止您这样做? Per-Se 我不明白为什么这是不可能的,那么你的代码在哪里?还是你没有代码?
-
我已经更新了问题
标签: php curl proxy soapserver