1

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:

<?php

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

require_once('../../../../Mage.php');
Mage::app();

$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
));

var_dump($soap);

echo $soap->__getLastResponse();

try {
$sessionID = $soap->login($mageUser, $mageApiKey);
}
catch (SoapFault $soapFault) {
    var_dump($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 '13 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 '13 at 13:37
2

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 '13 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 '13 at 15:36
  • But FYI, I don't get reasonable access when I point my script at those, only a browser. – user2045 Aug 19 '13 at 20:28
  • what response do you get when you run my code? – user2045 Aug 20 '13 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) } – Matthias Zeis Aug 20 '13 at 16:00

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.