我使用SoapClient连接到第三方服务。大多数的正常工作时间,但每过一段时间中,也许一次每100-150电话,我得到的错误从SoapFault获取错误的WSDL?
Soap Failed: SOAP-ERROR: Parsing Schema: unexpected in complexType
我的代码是在一个try/catch随着重试,它会通过下一轮工作。但是我想研究WSDL以找出失败的原因,部分原因是为了我自己的好奇心,并且需要将它传递给我所连接的公司。我可以从SoapFault获取这些信息吗?或者我必须调用URL来获取字符串?我担心如果在事实之后获得WSDL,它可能已经被修复。
$pass = FALSE;
$this->soap = NULL;
$this->session = NULL;
do {
try {
Doc::i("Starting session");
$this->soap = new SoapClient($this->wsdl_url, ['trace' => 1]);
$pass = TRUE;
} catch (\SoapFault $e) {
Doc::e('Soap Failed: ' . $e->getMessage());
if(str_contains($e->getMessage(),'Parsing Schema') && !empty($e->detail)) {
Doc::e($e->detail); // Something new I'm trying to see if it helps
}
} catch (FatalErrorException $e) {
Doc::e("Soap failed really bad: " . $e->getMessage());
} catch (\Exception $e) {
Doc::e("Soap failed bad: " . $e->getMessage());
}
} while (!$pass);
['__getLastResponse'](http://php.net/manual/en/soapclient.getlastresponse.php),因为你正在使用'trace'? – bishop
我发现'__getLastResponse()',并且只是添加了。我希望下次发生错误时能够正常工作。谢谢你的支持! – aynber
祝你好运!这些错误令人讨厌。我发布了一个正式的答案,以防最终解决。 – bishop