I'm using the script below to connect to the Magento API. When trying to connect with my script I've got:

SOAP Fault: (faultcode: Client faultstring: looks like we got no XML document)

If I enter the URL in my browser https://foo.com/api/v2_soap/?wsdl , I've received the default XML file.

I have created a soap user and role. Resource Access = All


$url = 'https://foo.com/api/v2_soap/?wsdl';

$client = new SoapClient($url);

try {
    //retreive session id from login
    $session_id = $client->login('username','password');
} catch (SoapFault $fault) {
    $error      =   "SOAP Fault: (faultcode: {$fault->faultcode}\n" ."faultstring: {$fault->faultstring})";
    echo $error;

Php version

Magento version Enterprise


Your WSDL XML might be erroneous/not valid.

After a quick Google I found this answer on StackOverflow: https://stackoverflow.com/a/12319009/1306684

I says there might be other output than the XML only. If you open the URL in your browser, then scroll all the way down to see if there is other output (like a PHP error).

If you open the WSDL in your browser, then you see something that looks like a pretty long and solid WSDL XML, but you cannot tell by sight if it is valid.

Try to validate it. You can just Google for a online WSDL validator.

Also do not forget to look for errors in your Magento's logs, check var/system.log and var/exception.log

  • I've got a short XML. It seems wrong param in wsdl file.<soap:address location="foo.com/bar_index.php/api/soap/index/?SID="> Where could I find this file to see settings?! – vadim vadim Jan 16 '16 at 13:53
  • Weird. Is it really missing http(s)://? And note the "?SID=" part. That shouldn't be there. Are you using the correct URL exactly the same as the base_url that you have configured? Else the API will try to "redirect" you and Magento will add a SID parameter – 7ochem Jan 16 '16 at 16:02
  • 1
    in browser adress url myurl.com/api/v2_soap/?wsdl and i've got a huge xml file but in <soap:address location="myurl.com/somefile_index.php/api/v2_soap/index/…> This file somefile_index.php is exist in root dir but i can't understand why it is called. Server is - nginx. Maybe the issue on the server's side?! – vadim vadim Jan 16 '16 at 16:20
  • I 've turned off Auto redirect to base url and I've got a new message SOAP-ERROR: Parsing WSDL: Couldn't load from 'myurl.com/index.php/api/v2_soap/?wsdl' : xmlParseEntityRef: no name" – vadim vadim Jan 18 '16 at 11:34

Open your php.ini file from your remote server or local server and set always_populate_raw_post_data to -1.

After that you need to restart your Apache server.

Once restart have done please run your script again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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