java - WSDL 文件在浏览器中加载,但不在代码中加载

标签 java php magento soap wsdl

我们正在尝试连接到我们的magentosoap/wsdl后端,当我们在浏览器中加载XML文件时,我们可以很好地加载它。

http://<url>/index.php/api/v2_soap?wsdl

但是当我们通过 wsimport(java) 生成的客户端或通过非常简单的 php 代码来执行此操作时:

<?php
  $proxy = new SoapClient('http://<url>/index.php/api/v2_soap?wsdl');
  $sessionId = $proxy->login('test', 'test');

  var_dump($proxy->call($sessionId, 'customer.list'));
?>

我们收到以下错误:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: 
Parsing WSDL: Couldn't load from 'http://<url>/index.php/api/v2_soap?wsdl' : 
Start tag expected, 
'<' not found in /home/test/public_html/test_api.php:3 
Stack trace: 
#0 /home/test/public_html/test_api.php(3): 
SoapClient->SoapClient('http://<url>...') 
#1 {main} thrown in 
/home/test/public_html/test_api.php on line 3

如果我们在浏览器中打开与上面相同的内容,但没有 ?wsdl:

http://<url>/index.php/api/v2_soap

它也会导致相同的解析错误。

用户名和api key 正确,并且用户所在的组具有完整的权限。

更新: 我们还尝试了 SoapUI这给出了同样的错误。

这是我们从浏览器访问 URL 时得到的开始:

<wsdl:definitions xmlns:typens="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Magento" targetNamespace="urn:Magento">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<xsd:complexType name="associativeEntity">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
<xsd:element name="value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="associativeArray">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray" type="typens:associativeEntity"/>
</xsd:sequence>
</xsd:complexType>

最佳答案

我们刚刚花了两天时间。为我们解决这个问题的方法是打开位于系统 -> 缓存管理下的Web服务配置缓存。

所以你应该离开这个......

a picture of the configuration having the web services configuration cache turned off

对此...

a picture of the configuration having the web services configuration cache turned on

关于java - WSDL 文件在浏览器中加载,但不在代码中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20234353/

相关文章:

php - 如何按组 ID 计算 php 中 SQL 列的平均值并显示在 HTML 页面上?

java - 在 Android 中显示/隐藏 WebView

Java - 通过大型字符串列表改进迭代

Java Spring——在编译时识别语法错误(在 Eclipse 中)

php - 如何动态设置模板属性(包括CSS)PHP

php - 导入表时未知列名

xml - 自定义模块中的 Magento Layout xml 不起作用

javascript - 销售在 Magento 报告中不起作用

Magento - 获取产品集合的结果 View HTML

java - 在 Java 中查找另一个数组中的数组的最快方法是什么?