我试图做用PHP服务器的SOAP请求,但所有我得到的是“无法连接到主机”运行如何在PHP中调试SOAP?
$this->client->__soapCall("aMethod()", [$request_param_array]));
我认为WSDL是好的时候,因为我能达到它在浏览器中运行
$this->client->__getFunctions();
当我收到可用功能的列表(在这个WSDL指定)。
我确实需要一个证书做SOAP调用到该服务器,所以也许这就是这个问题?但我不知道我怎么能调试什么导致此“无法连接到主机”错误。
任何想法是什么可以导致这种错误发生或我怎么能找到问题?
我迄今为止代码:
public function __construct($url, $wsdl = null)
{
$this->wsdl = $wsdl != null ? $wsdl : $url . '?wsdl';
$this->client = new SoapClient($this->wsdl, array(
"trace" => "1",
"local_cert" => realpath(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "..") . "cert.pfx",
"passphrase" => "admin",
));
Log::info(sprintf("New SoapClient created with WSDL: '%s'", $this->wsdl));
}
感谢您的评论!我的确发现了这些解决方案,但这种调试方式的缺点是证书错误发生在实际的请求之前。所以当有某种连接失败时,不可能使用getLastResponse()的getLastRequest()方法。 – Kevin