我試圖做用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