我完全陷入了SOAP集成。我已经搜索并不断寻找如何使其正确的方法。我的系统需要连接到某个Web服务。 URL将我重定向到?wsdl页面。 我正在使用SOAPUI提交请求,它正在给我正确的响应。我也使用了SOAPClient但无济于事。我认为这一天不再常用了。我无法找到我的错误。任何人都可以用这个来启发我吗?先谢谢你。
SOAPUI请求如下所示。它给了我正确的反应:
POST https://example.com/blah/blah/Upload_v1_Port HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="upload_v1_Binder_ping"
Content-Length: 205
Host: bm-webservices-test.example.com.au
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Cookie: TS01128e1b=01c05e74c88cb127b6ba1e3cd907936f06957fdeead8e6f308ed6281d48b5da0dbb51b6ca0
Cookie2: $Version=1
Authorization: Basic <username:password>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:dir="http://test.com/mrb/ws/upload">
<soap:Header/>
<soap:Body>
<dir:ping/>
</soap:Body>
</soap:Envelope>
这是我的PHP书面代码:
$credentials = "username:password";
$headers = array(
"POST https://example.com/blah/blah/Upload_v1_Port HTTP/1.1",
"Accept-Encoding: gzip,deflate",
"Content-Type: application/soap+xml;charset=UTF-8;action=upload_v1_Binder_ping",
"Content-Length: 205",
"Host: bfs-ws-test.test.com.au",
"Connection: Keep-Alive",
"User-Agent: Apache-HttpClient/4.1.1 (java 1.5)",
"Cookie: TS01128e1b=01c05e74c88cb127b6ba1e3cd907936f06957fdeead8e6f308ed6281d48b5da0dbb51b6ca0",
"Cookie2: $Version=1",
"Authorization: Basic $credentials",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://www.test.com/upload');
curl_setopt($ch, CURLOPT_CERTINFO, CACERT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_file);
$data = curl_exec($ch);
//pre_print_r($data); exit();
pre_print_r(curl_getinfo($ch));
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
} else {
echo 'test';
pre_print_r($data);
curl_close($ch);
}
这是我得到的结果:
</pre><hr>test<pre>--MIMEBoundary_ceea4229e38f12b7cd400440c7bdc1c1fe376164e3efa031
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.deea4229e38f12b7cd400440c7bdc1c1fe376164e3efa031@apache.org>
<faultstring>[ISS.0088.9171] Operation not found for soapAction = null</faultstring>
答案 0 :(得分:0)
解决方案:
它可能是由HTTP POST中的错误Content-Type
引起的。在标题中设置text/xml
可以解决问题。
答案 1 :(得分:-1)
你有2个语法错误:
$headers = array(
"POST https://example.com/blah/blah/Upload_v1_Port HTTP/1.1",
Accept-Encoding: gzip,deflate //no quotes no comma
"Content-Type: application/soap+xml;charset=UTF-8;action="upload_v1_Binder_ping", //3 qootes.
"Content-Length: 205",
"Host: bfs-ws-test.test.com.au",
"Connection: Keep-Alive",
"User-Agent: Apache-HttpClient/4.1.1 (java 1.5)",
"Cookie: TS01128e1b=01c05e74c88cb127b6ba1e3cd907936f06957fdeead8e6f308ed6281d48b5da0dbb51b6ca0",
"Cookie2: $Version=1",
"Authorization: Basic $credentials",
);
或者问题只是一个错字。