Magento 1.9 SOAP API – SOAP Error: Procedure ‘loginParam Not Present’

magento-1.9soapsoap-api-v2

I'm getting a soap error, and I haven't been able to trace it. It is blocking an integration and generally causing havoc. Since it is happening immediately with login, I haven't been able to trace it further.

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Procedure 'loginParam' not present

reflected similarly in the apache error log:

PHP Fatal error:  Procedure 'loginParam' not present in /var/www/html/lib/Zend/Soap/Server.php on line 889

This occurs when trying to log in with a valid username/password (which work on the v1 API):

$api_url_v2 = "https://xxx/api/v2_soap/?wsdl=1";
$cli = new SoapClient($api_url_v2);
$session_id = $cli->login($username, $password);

I've tried flushing my WSDL cache, as suggested here:
https://stackoverflow.com/questions/12425909/magento-soap-2-api-fatal-error-procedure-login-not-present

I've also tried modifying my WSI-Compliance settings, to no avail.

Any help would be appreciated.


Additional info:
I traced out the incoming client call, and see this… although it certainly doesn't look right to me, I've never been a SOAP guy:

<?xml version="1.0" encoding="UTF-8"?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento"><SOAP-ENV:Body><ns1:loginParam/><param1>{SOME_PASSWORD}</param1></SOAP-ENV:Body></SOAP-ENV:Envelope>

The headers look like this:

{"Host":"some-server.com","Connection":"Keep-Alive","User-Agent":"PHP-SOAP\\/5.6.20","Content-Type":"text\\/xml; charset=utf-8","SOAPAction":"\\"\\"","Content-Length":"235"}

So… my username appears to have been lost, and I'm not even sure if it is calling the right thing.

Best Answer

For your login call, you need to format the passed parameters as an array -

$api_url_v2 = "https://xxx/api/v2_soap/?wsdl=1";
$cli = new SoapClient($api_url_v2, array('trace' => 1));
$session_id = $cli->login(array('username' => $username, 'apiKey' => $password));

The array('trace' => 1) parameter on the SoapClient " enables tracing of request so faults can be backtraced. This defaults to FALSE" src: php docs

This could be useful while experimenting with a new api implementation.

Related Topic