I have just started learning magento.

I was trying to use magento SOAP services. For that I have created SOAP user and SOAP user role. Assigned role to user.

Now, my code to access SOAP service is something like this.

$client = new SoapClient('http://HOST_NAME/index.php/api/v2_soap/?wsdl');
$sessionId = $client->login('USER_XX', 'XXXXXX');

here I got proper object to $client but when I try to login with that I am getting this error. Output of above code is:

SoapClient Object
    [_soap_version] => 1
    [sdl] => Resource id #2

Fatal error:  Uncaught SoapFault exception: [Client] DTD are not supported by SOAP in /PATH_TO_FOLDER/test.php:6
Stack trace:
#0 /PATH_TO_FOLDER/test.php(6): SoapClient->__call('login', Array)
#1 /PATH_TO_FOLDER/test.php(6): SoapClient->login('USER_XX', 'XXXXXX')
#2 {main}
  thrown in /PATH_TO_FOLDER/test.php on line 6

After some googling I came to know that above error occurs because webservice returning some html response. For like 404, 403 or 500 server errors.

So I have checked same webservice using software "SoapUI" and I got this result.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
      <title>Server error!</title>
      <link rev="made" href="mailto:[email protected]"/>
      <style type="text/css">
    body { color: #000000; background-color: #FFFFFF; }
    a:link { color: #0000CC; }
    p, address {margin-left: 3em;}
    span {font-size: smaller;}
      <h1>Server error!</h1>
      <p>The server encountered an internal error and was 
    unable to complete your request. Either the server is
    overloaded or there was an error in a CGI script.</p>
         If you think this is a server error, please contact
         <a href="mailto:[email protected]">webmaster</a>
      <h2>Error 500</h2>
         <a href="/">b2c.biodis.ch</a>
            Thu Apr 23 10:45:35 2015

Do you have any idea what's going wrong?

Thank you.

3 Answers 3


Resolved: Issue was

Duplicate Content-Type header on API responses | MageGyver

At file app/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php

function run previous like this :

    ->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset)
    ->setHeader('Content-Length', strlen($content), true)

Changed it to:

    ->setHeader('Content-Type', 'text/xml; charset=' . $apiConfigCharset, true) // <== Included true
    ->setHeader('Content-Length', strlen($content), true)

You can try passing the arguments as an array. Like this:

$session = $client->login(array('username' => $mage_user, 'apiKey' => $mage_api_key));

In addition to Sohil Desai's answer I required an additional step. On updating our server we decided that, to please Google, we'd send all traffic HTTPS. So the original SOAP url:


Did not work and gave Server 500. We needed to change the protocol AND remove the port number and it worked.


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.