Magento SOAP API-登录方法调用引发PHP异常:“看起来我们没有XML文档" [英] Magento SOAP API - PHP Exception thrown for login method call: "looks like we got no XML document"

查看:73
本文介绍了Magento SOAP API-登录方法调用引发PHP异常:“看起来我们没有XML文档"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过PHP的SoapClient连接到Magento SOAP API时遇到问题.我在开发服务器上使用以下代码安装了一个小型测试PHP文件:

I'm having issues connecting to the Magento SOAP API via PHP's SoapClient. I have a small test PHP file setup on my dev server with the following code:

<?php
$soapC = new SoapClient('http://XXXX.com/api/soap/?wsdl', array('trace'=>true, 'exceptions'=>false));
$session = $soapC->__soapCall('login', array('TestUsr', 'test123'));
var_dump($session);
?>

PHP文件与我的magento开发版本位于同一服务器上.当我通过命令行运行php脚本时,$ session变量会输出一个SoapFault对象,并显示一条错误消息看起来好像我们没有XML文档".

The PHP file is on the same server as my magento dev build. When I run the php script via the command line, the $session variable outputs a SoapFault object with an error that says "looks like we got no XML document".

不确定如何解决此问题.当我尝试下面的代码时,我可以从所有API方法中打印出来,但是由于某种原因,上面的login方法调用引起了问题.

Not sure how to resolve this. When I try the code below I'm able to get a print out of all of the API methods, but for some reason the login method call above is causing problems.

$soapC = new SoapClient('http://XXXX.com/api/soap/?wsdl', array('trace'=>true, 'exceptions'=>false));
print_r($soapC->__getFunctions());

推荐答案

我意识到问题是,当服务器尝试访问wsdl文件时,Magento发出了指向店面的302重定向.

I realized the issue was that when the server tried to access the wsdl file, Magento was issuing a 302 redirect to the storefront.

要修复此问题,我登录了Magento管理面板,导航至系统"->配置"->"Web",然后关闭了自动重定向到基本URL".现在就像魅力一样.

To fix it, I logged into the Magento admin panel, navigated to System -> Configuration -> Web, and turned off "Auto-redirect to Base URL". Works like a charm now.

这篇关于Magento SOAP API-登录方法调用引发PHP异常:“看起来我们没有XML文档"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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