我们正在尝试连接到我们的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服务配置
缓存。
所以你应该离开这个......
对此...
关于java - WSDL 文件在浏览器中加载,但不在代码中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20234353/