我在 php 中与 SOAP 服务通信时遇到问题:我的客户端代码:
$url = "https://XXXX.com/DataService.svc?singleWsdl";
$client = new SoapClient($url);
var_dump($client->__getFunctions()); // ExportScheduleData(ExportScheduleData $parameters)
$aclient->ExportScheduleData(array());
我得到了:
Uncaught SoapFault exception: [HTTP] Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.
将 SOAP 版本更改为 1.2:
$client = new SoapClient($url, array('soap_version' => SOAP_1_2));
并且请求无法完成:当我刷新页面时,它仍然处于闲置状态 - 任何错误左右。
===== 更新 =====
看起来服务使用 WS-Security。它们提供证书文件,但是:
Warning: SoapClient::SoapClient(): Unable to set local cert chain file `C:xampphtdocsworkspacesandbox.devpublicsandbox.cer'; Check that your cafile/capath settings include details of your certificate and its issuer in C:xampphtdocsworkspacesandbox.devpublicsandbox.php on line 34
已解决。编写一个用于 ws-secutity 检查的 Java 应用程序,并从 php 脚本查询 java 应用程序。我使用java tcp服务器。