无法加载外部实体

时间:2016-03-17 10:51:18

标签: php web-services soap wsdl fedex

我正在尝试集成fedex API并收到此错误。

  

警告:SoapClient :: SoapClient()[soapclient.soapclient]:I / O警告:无法加载外部实体" ../ wsdl / RateService_v13.wsdl"在第12行的test.php中

     

致命错误:未捕获的SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法从' ../ wsdl / RateService_v13.wsdl'加载在D:\ wamp \ www \ fedexapi \ AddressValidationService_v4_php \ php \ AddressValidationWebServiceClient \ rate_test.php:12堆栈跟踪:#0 D:\ wamp \ www \ fedexapi \ AddressValidationService_v4_php \ php \ AddressValidationWebServiceClient \ rate_test.php(12):SoapClient- >第12行的test.php中抛出的SoapClient(' ../ wsdl / RateSer ...',数组)#1 {main}

<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 2.0.0

require_once('../library/fedex-common.php5');

//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../wsdl/LocationsService_v3.wsdl";

ini_set("soap.wsdl_cache_enabled", "0");

$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information

$request['WebAuthenticationDetail'] = array(
        'ParentCredential' => array(
            'Key' => getProperty('parentkey'),
            'Password' => getProperty('parentpassword')
        ),
        'UserCredential' => array(
            'Key' => getProperty('key'), 
            'Password' => getProperty('password')
    )
);

?>

如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

Afaik SoapClient第一个参数需要是一个URI,而不是磁盘上的本地文件名。

错误表明无法加载wsdl。 请查看specsthis expample是否应该明确。

答案 1 :(得分:0)

相对路径也有效。

就我而言,我必须修复wsdl文件的相对路径。