在 PHP 中,如果您尝试实例化一个新的 SoapClient,并且 WSDL 不可访问(服务器停机或其他),抛出 PHP 致命错误:
In PHP, if you try to instantiate a new SoapClient, and the WSDL is not accessible (server down or whatever), a PHP fatal error is thrown:
致命错误:SOAP-ERROR:解析 WSDL:无法加载'http://example.com/servlet/app/SomeService?wsdl': 无法加载外部实体"http://example.com/servlet/app/SomeService?wsdl">
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://example.com/servlet/app/SomeService?wsdl' : failed to load external entity "http://example.com/servlet/app/SomeService?wsdl"
PHP 中的致命错误,据我所知,无法恢复.
Fatal errors in PHP, as far as I know, are not recoverable.
有什么办法可以退缩吗?能否以某种方式避免这种致命错误?
Is there any way to fallback from this? Can this fatal error somehow be avoided?
我应该说我在 PHP 5.2 上运行,如果它有什么不同的话.
I should say that I am running on PHP 5.2, if it makes any difference.
这个已经讨论过了:
Rasmus 本人提出了以下解决方案:
Rasmus himself proposed the following solution:
<?php
try {
$x = @new SoapClient("non-existent.wsdl",array("exceptions" => 1));
} catch (SoapFault $E) {
echo $E->faultstring;
}
echo "ok
";
这篇关于PHP 中的 SoapClient 错误回退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 PHP 上启用 SOAPenable SOAP on PHP(在 PHP 上启用 SOAP)
从 PHP SOAP 服务器获取接收到的 XMLGet received XML from PHP SOAP Server(从 PHP SOAP 服务器获取接收到的 XML)
不是有效的 AllXsd 值not a valid AllXsd value(不是有效的 AllXsd 值)
PHP SoapClient:SoapFault 异常无法连接到主机PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 异常无法连接到主机)
PHP中P_SHA1算法的实现Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的实现)
将字节数组从 PHP 发送到 WCFSending a byte array from PHP to WCF(将字节数组从 PHP 发送到 WCF)