由于“无法加载外部实体",因此无法连接到Magento SOAP API v2. [英] Unable to connect to Magento SOAP API v2 due to "failed to load external entity"

查看:131
本文介绍了由于“无法加载外部实体",因此无法连接到Magento SOAP API v2.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用PHP连接到Magento SOAP API v2.发生的错误是:

I am unable to connect to the Magento SOAP API v2 using PHP. The error that occurs is:

PHP致命错误:未捕获的SoapFault异常:[WSDL] SOAP错误:解析WSDL:无法从' http://www.example.com/index. php/api/v2_soap/index/wsdl/1/"

PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.example.com/index.php/api/v2_soap/index/wsdl/1/' : failed to load external entity "http://www.example.com/index.php/api/v2_soap/index/wsdl/1/"

看起来,正在加载WSDL,但其中未包含外部SOAP文件.

As it seems, the WSDL is being loaded, but the external SOAP file which it includes not.

PHP连接代码:

$client = new SoapClient('http://www.example.com/api/v2_soap?wsdl=1');
$session = $client->login('username', 'password');


从v2_soap?wsdl = 1文件中摘录:


Snip from v2_soap?wsdl=1 file:

<service name="MagentoService">
    <port name="Mage_Api_Model_Server_V2_HandlerPort" binding="typens:Mage_Api_Model_Server_V2_HandlerBinding">
        <soap:address location="http://www.example.com/index.php/api/v2_soap/index/"/>
    </port>
</service>


Magento版本为1.5.1.0.

推荐答案

此问题是由服务器无法从本地计算机访问文件引起的.因此,可能的原因可能是DNS服务器或/etc/hosts,但实际上是一个.htaccess文件,阻止了除我们开发计算机以外的所有主机.这导致了403 Forbidden错误,从而导致SOAP错误,等等.

This problem is caused by the server not being able to access the file from the local machine. So the possible cause could've been the DNS server or /etc/hosts, but it was actually a .htaccess file blocking any hosts except from our development computers. This resulted in a 403 Forbidden error, which resulted in the SOAP error and so on..

这篇关于由于“无法加载外部实体",因此无法连接到Magento SOAP API v2.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆