Magento – Can’t connect via SOAP v1

soap

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?

Best Answer

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.

Related Topic