I am trying to set up a SOAP client on one server to communicate with Magento on a test server. Both servers have PHP's SOAP extension installed, configured and show up in phpinfo().

Tried turning off caching, using the v2 and v1 APIs and everything else I could think of. Regardless, I keep getting the same problems.

Either its:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
                    Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: 
                    Couldn't find <definitions> in 'http://myserver.com/api/v2_soap?wsdl=1' 
                    in dispatch.php:39 

                    Stack trace: #0 dispatch.php(39): 
                    SoapClient->SoapClient('http://myserver.com/...', Array) #1 {main} thrown

or sometimes another error SOAP doesn't allow DTD....

I'm now using just the plain Magento example code from here, instead of running anything significant, until I can figure out what's going on with this.

If I do file_get_contents to the service URL, I get:

<?xml version="1.0" encoding="UTF-8"?>
<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/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="Magento" targetNamespace="urn:Magento">
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
        <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
        <complexType name="associativeEntity">
            <element name="key" type="xsd:string"/>
            <element name="value" type="xsd:string"/>

So seems like it should not have trouble parsing this.. idk.

1 Answer 1


Apparently I fell prey to a common Magento pitfall, so I'm posting the answer in case anyone else is searching this particular error. Basically, the error was coming from the Magento installation I was trying to call via the SOAP API.

Initially I thought the error was generated by the client being unable to locate this definitions result, however the real situation is as follows.

  • The Magento installation which is acting as a SOAP server makes some SOAP client calls to itself.
  • These calls lookup the same domain you are accessing in your client script, but originate from the sever on which that domain is hosted and loopback to said server.
  • Therefor, you need to check your host file, usually at /etc/hosts for Linux distros and try to append Your.IP.Address.Here Your.Magento.Domain (i,e magentohost.com)
  • Ensure that iptables allows loopback connections, especially if you try to run localhost instead of your external IP; but most likely you'll need to use the external IP address.

That's it; once I edited the file: /etc/hosts and added this one line, everything worked fine.

If anyone has clearer insight or a generally better answer - please feel free to post and it will most likely be accepted over this answer.

  • This didn't help me fix it..Any other guess what could be the reason? Oct 24, 2018 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.