【发布时间】:2013-07-08 21:37:06
【问题描述】:
我有一个带有 CentOS 6、Apache 2.2、PHP 5.4 的云服务器,并且我有一个带有 Magento 的站点。 我尝试使用 Magento WebService 并返回此错误:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://******.com/dev/index.php/api/soap/index/?wsdl=1' : failed to load external entity "http://******.com/dev/index.php/api/soap/index/?wsdl=1"
我在这里和谷歌搜索,我尝试在 php.ini 中进行许多更改,但在所有情况下我都没有成功。
我读到在某些情况下这是服务器端的问题,因为配置错误。
注意¹:SOAP 安装在服务器中,在 phpinfo() 中启用了 SOAP。
注意²:在另一台服务器上工作正常。
有人知道如何解决这个问题吗?
编辑:服务器使用 WHM/CPanel,我使用 EasyApache 安装 Apache、PHP。并使用默认配置。
Edit2:这只是一个使用 SOAP 的简单示例代码及其返回的错误:
代码:(这段代码的第一行是第9行,第13行是“$cli = new SoapClient($api_url_v1);”)
<?php
$api_url_v1 = "http://site.com/dev/api/soap/?wsdl=1";
$username = '*********';
$password = '*********';
$cli = new SoapClient($api_url_v1);
//retreive session id from login
$session_id = $cli->login($username, $password);
//call customer.list method
$result = $cli->call($session_id, 'customer.list', array(array()));
?>
错误:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://site.com/dev/api/soap/?wsdl=1' : failed to load external entity "http://site.com/dev/api/soap/?wsdl=1" in /home/******/public_html/test_soap.php:13 Stack trace: #0 /home/******/public_html/test_soap.php(13): SoapClient->SoapClient('http://site...') #1 {main} thrown in /home/******/public_html/test_soap.php on line 13
【问题讨论】:
-
服务器上是否安装了 CURL?
-
是的,“cURL 支持:已启用”。 ;)
-
我没有用于 https 的 SSL 证书,但在 PHP 中启用了 openssl。 "OpenSSL 支持:已启用"
-
请添加所有必要的信息,如代码清单。如您所见,两个错误指向两个不同的事物。
-
Kamil 第一个错误是我使用第三方 API 时引起的,因此无法访问代码,但我知道这是我之前使用的共享主机上运行的功能代码。第二个代码我复制了这里的一篇文章“stackoverflow”(如果我没记错的话)来测试 SOAP 的功能并返回这个错误。并且这两个错误是相等的,唯一的区别是第二个它显示了导致错误的文件。可能不是开发者选择的第一个节目。