El archivo WSDL se carga en el navegador, pero no en el código

We are trying to connect to our magento soap/wsdl backend, we can load the XML file just fine when we are loading it in the browser.

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

But when we do it through a wsimport(java) generated client or through the very simple php code:

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

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

Obtenemos el siguiente error:

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

If we open the same as above but without ?wsdl en un navegador:

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

it also results in the same parsing error.

The username and api key is correct and the group that the user is in has full rights.

Actualizar: We also tried with SoapUI which gave the same error.

This is the beginning of what we get when visiting the URL from a browser:

<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>

preguntado el 27 de noviembre de 13 a las 05:11

4 Respuestas

We just spent two days on this. What solved it for us was turning on the Web Services Configuration cache, located under System -> Cache Management.

So you should go from this...

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

a esto...

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

respondido 28 nov., 13:05

If the parse error persists even when it is being opened in the browser then i think there must some error in the SOAP Server (May be Syntax Error)

respondido 27 nov., 13:05

It does work when we open it in the browser, just not when we remove the wsdl part. So this works in the browser http://<url>/index.php/api/v2_soap?wsdl pero no esto http://<url>/index.php/api/v2_soap - Spydon

I'm not sure how I can get the request xml or SOAP Envelope as it crashes when it builds them from the definition file, if I have understood everything correctly? Do you have any recommendation of how to print them? - Spydon

You said earlier that you can see the wsdl in the browser so what does it show. U can find the SOAP Envelope there only - Soumik Sur

This is the XML I get when visiting the URL: pastebin.com/ZpKwqFzQ , but is that really the SOAP Envelope? - Spydon

can u post the first 20 lines of the xml that you are getting - Soumik Sur

<?php
    $soap_client = new SoapClient("http://<url>/index.php/api/v2_soap?wsdl");
    $info = new StdClass();
    $info->key = "test";
    $info->value = "test";
    $param = array($info);
    $result = $soap_client->__soapCall('customer.list',$param);
    var_dump($result);
?>

Try this code.... From the xml i saw it seems your wsdl does not require any authentication for the connection.

Hope you find this code of some help...

respondido 27 nov., 13:07

I was facing the same problem and this trick did the job for me:

Todo lo que hice fue:

cambio:

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

a

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

Notice the question mark "?" in the first link replaced with a period "." in the second link just before "wsdl" at the end.

Respondido el 14 de enero de 17 a las 00:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.