首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SoapClient LibXMLError:无法加载外部实体,SOAP-错误:分析WSDL:无法加载

SoapClient LibXMLError:无法加载外部实体,SOAP-错误:分析WSDL:无法加载
EN

Stack Overflow用户
提问于 2012-04-25 23:10:55
回答 3查看 29.7K关注 0票数 2

我尝试使用以下PHP代码建立SOAP连接,但在SoapClient构造点上失败了:

代码语言:javascript
复制
// Need to declare these settings here because our php.ini has alternate
// settings due to global purposes for other PHP scripts
ini_set("soap.wsdl_cache_enabled", "0");
ini_set("soap.wsdl_cache", "0");
ini_set("display_errors","On");
ini_set("track_errors","On");

// FedEx web services URL, note the HTTPS
$path_to_wsdl = 'https://wsbeta.fedex.com/web-services';

$soap_args = array(
    'exceptions'=>true,
    'cache_wsdl'=>WSDL_CACHE_NONE,
    'trace'=>1)
;

try {
    $client = new SoapClient($path_to_wsdl,$soap_args);
} catch (SoapFault $e) {
    var_dump(libxml_get_last_error());
    echo "<BR><BR>";
    var_dump($e);
}

这将输出以下内容:

代码语言:javascript
复制
object(LibXMLError)#1 (6) {
    ["level"]=> int(1)
    ["code"]=> int(1549)
    ["column"]=> int(0)
    ["message"]=> string(71) "failed to load external entity "https://wsbeta.fedex.com/web-services" "
    ["file"]=> string(0) ""
    ["line"]=> int(0)
}

object(SoapFault)#2 (9) {
    ["message":protected]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://wsbeta.fedex.com/web-services' : failed to load external entity "https://wsbeta.fedex.com/web-services" "
    ["string":"Exception":private]=> string(0) ""
    ["code":protected]=> int(0)
    ["file":protected]=> string(53) "/mnt/array/bell-enterprise/bell/fedex_shipservice.php"
    ["line":protected]=> int(34)
    ["trace":"Exception":private]=> array(1) {
        [0]=> array(6) {
            ["file"]=> string(53) "/mnt/array/bell-enterprise/bell/fedex_shipservice.php"
            ["line"]=> int(34)
            ["function"]=> string(10) "SoapClient"
            ["class"]=> string(10) "SoapClient"
            ["type"]=> string(2) "->"
            ["args"]=> array(2) {
                [0]=> string(37) "https://wsbeta.fedex.com/web-services"
                [1]=> array(4) {
                    ["exceptions"]=> bool(true)
                    ["soap_version"]=> int(1)
                    ["cache_wsdl"]=> int(0)
                    ["trace"]=> int(1)
                }
            }
        }
    }
    ["previous":"Exception":private]=> NULL
    ["faultstring"]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://wsbeta.fedex.com/web-services' : failed to load external entity "https://wsbeta.fedex.com/web-services" "
    ["faultcode"]=> string(4) "WSDL"
}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-08-07 05:59:21

在经历了6个小时的头痛之后,唯一的解决方案是下载WSDL文件。

https://wsbeta.fedex.com/web-serviceshttps://ws.fedex.com/web-services

它将总是抛出错误500,因为这不是wsdl。

一旦您从技术资源-> FedEx WebServices -> Shipping -> GetStarted下载了wsdls (单击"Rate Services“,然后单击"Download WSDL or XML"),在您的脚本中,您将需要加载本地存储的WSDL,一切都将工作得如鱼得水。

代码语言:javascript
复制
$this->_soapClient = new SoapClient("RateService_v13.wsdl", array('exceptions'=>true, 'trace' => true));

玩得开心!

票数 8
EN

Stack Overflow用户

发布于 2013-04-25 02:14:30

该url不是WSDL的路径,而是SOAP请求应该到达的url。我从未与这些人合作过,但我想您可以在某个地方获得一个wsdl文件并将其存储在本地,并且可以将该wsdl中的端点更改为wsbeta端点。我找不到wsdl,联邦快递网站也不允许我在没有注册的情况下访问他们的开发技术资源,所以我就不说了:你的wsdl在别的地方,你拥有的url只是一个特定服务的位置。

票数 2
EN

Stack Overflow用户

发布于 2012-04-25 23:16:52

您需要一个本地证书文件来访问HTTPS上的WSDL:

代码语言:javascript
复制
$client = new SoapClient($wsdl, array('local_cert' => $pathToLocalCert));

将此选项附加到您当前的$soap_args,此代码应该可以按预期工作。如果证书需要passphrase选项,也可以使用该选项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10318526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档