我正在尝试集成联邦快递 API 并收到此错误。
警告:SoapClient::SoapClient() [soapclient.soapclient]:I/O 警告:无法加载外部实体"../wsdl/RateService_v13.wsdl" 在测试中.php在第 12 行
致命错误: 未捕获的 Soap错误异常: [WSDL] 肥皂错误: 解析 WSDL: 无法从"../wsdl/RateService_v13.wsdl' in 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->SoapClient('../wsdl/RateSer...', Array) #1 {main} 在测试中抛出.php在第 12 行
<?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')
)
);
?>
如何解决这个问题?
Afaik the SoapClient 的第一个 aprameter 需要是一个 URI,而不是磁盘上的本地文件名。
该错误指示它无法加载 wsdl。看看规格,这个扩展应该很清楚。
相对路径也有效。
就我而言,我必须修复 wsdl 文件的相对路径。