Error with PHP SOAP and Magento WebService


Error with PHP SOAP and Magento WebService

我有一个带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,我使用EasyPache安装Apache、PHP。并使用默认配置。

第2版:这只是一个简单的示例代码,它使用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

尝试通过web浏览器获取wsdl。如果这不起作用,那么你在url中有一个错误。试试www版本的url,检查是否有错误的重写,检查htaccess。你不需要https!