I am trying to point a php SoapClient at http://me.com/api/?wdsl and when I call $soap->login(), I get:

"PHP Fatal error: Uncaught SoapFault exception: [Sender] DTD are not supported by SOAP in ..."

I have tried adding options to the SoapClient constructor but nothing works. Any ideas? My code is as follows:


ini_set("soap.wsdl_cache_enabled", "0");  


$mageUrl    = 'http://me.com/api.php?type=soap&wsdl=1';
$mageUser   = 'XXXXX';
$mageApiKey = 'XXXXX';

$soap = new SoapClient($mageUrl,
        array( 'soap_version'=>SOAP_1_2, 'trace'=>1,     'user_agent'=>'SoapMasterFlex',
        'login' => 'XXXXX', 'password'=>'XXXXX',
'trace' => 1, 'exceptions' => true


echo $soap->__getLastResponse();

try {
$sessionID = $soap->login($mageUser, $mageApiKey);
catch (SoapFault $soapFault) {
    echo "Request :<br>", htmlentities($soap->__getLastRequest()), "<br>";
    echo "Response :<br>", htmlentities($soap->__getLastResponse()), "<br>";

Maybe someone could try making something like this work on their install?

  • Also, I have added that mage user and mage api key via the web services toolbar FWIW.
    – user2045
    Aug 19, 2013 at 13:32
  • Also, this might help: For me, this code throws an exception upon $soap->login(), then after complaining about the DTD it appears to return the magento admin login screen in HTML. I'm fairly certain that the issue is that SOAP wants XML output but that login call is outputting HTML but I don't know how to get it to output anything else.
    – user2045
    Aug 19, 2013 at 13:37

1 Answer 1


For me your script worked both with http://www.domain.tld/api/soap/?wsdl and http://www.domain.tld/api/?wsdl. The URL containing api.php return the code for the homepage.

Do you get an XML response if you call one of the two mentioned URLs in your web browser? Because you should.

  • I get a reasonable XML response when I access: domain.tld/api/?wsdl
    – user2045
    Aug 19, 2013 at 14:59
  • I also get a reasonable XML response when I access: www.domain.tld/api.php?type=soap&wsdl=1
    – user2045
    Aug 19, 2013 at 15:36
  • But FYI, I don't get reasonable access when I point my script at those, only a browser.
    – user2045
    Aug 19, 2013 at 20:28
  • what response do you get when you run my code?
    – user2045
    Aug 20, 2013 at 14:48
  • The output of your code: class SoapClient#51 (6) { public $_login => string(10) "ImportTest" public $_password => string(6) "123123" public $trace => int(1) public $_user_agent => string(14) "SoapMasterFlex" public $_soap_version => int(2) public $sdl => resource(195) of type (Unknown) } Aug 20, 2013 at 16:00

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.