3

Hi i am using magento vesion 1. 9 and i am trying to call magento soap apiv2 using php.

i use the following code.

$proxy = new SoapClient('http://domain/index.php/api/v2_soap/?wsdl=1');
$sessionId = $proxy->login((object)array('username' => 'user', 'apiKey' => 'password'));
$product = $proxy->catalogProductInfo((object)array('sessionId' => $sessionId->result, 'productId' => '27'));

i get the session id (i testes it by printing the id) but when i make a soap call

$product = $proxy->catalogProductInfo((object)array('sessionId' => $sessionId->result, 'productId' => '27'));

the browser showing "Server error"

api user having full permission in the back end. but still it is not working. please some one help me to find the solution.

5
  • 1
    Please update your question to include the following information: Is there a product with given ID in the catalog? When running the snippet from command line, what is the result? Are there any log entries? Did you enable WS-I Compliance mode via system configuration?
    – mam08ixo
    Commented Oct 21, 2015 at 14:11
  • Yest i have that product with the id "27" and WS-I Compliance is enabled from configuration settings.
    – Arul James
    Commented Oct 23, 2015 at 5:28
  • hi Marius, i am try with your code : justpaste.it/577kd and o/p : snag.gy/TMBNim.jpg can i get help? @Marius
    – zus
    Commented Nov 13, 2018 at 10:16
  • @zus. It's not my code. I didn't write this answer
    – Marius
    Commented Nov 13, 2018 at 11:03
  • @Marius really sorry, misunderstanding?
    – zus
    Commented Nov 13, 2018 at 11:24

2 Answers 2

3

Change the getProductInfo call to this

$product = $proxy->catalogProductInfo($sessionId->result , 27);
4
  • Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Error cannot find parameter in /opt/lampp/htdocs/magento_test/api_test.php:4 Stack trace: #0 /opt/lampp/htdocs/magento_test/api_test.php(4): SoapClient->__call('catalogProductI...', Array) #1 /opt/lampp/htdocs/magento_test/api_test.php(4): SoapClient->catalogProductInfo('2d914eed03509e3...', 27) #2 {main} thrown in /opt/lampp/htdocs/magento_test/api_test.php on line 4
    – Arul James
    Commented Oct 23, 2015 at 5:25
  • Above is the error what i am getting. what will be the problem?
    – Arul James
    Commented Oct 23, 2015 at 5:26
  • I don't know what the new problem is
    – Marius
    Commented Oct 23, 2015 at 6:56
  • i think the problem is in my magento package. i tried the same code in new magento install package and it is working fine. i don't know what is the problem in my current magento package. anyway thanks brother for your help. :)
    – Arul James
    Commented Oct 23, 2015 at 7:28
0

You can try like this way..

    $proxy = new SoapClient('http://domain/index.php/api/v2_soap/?wsdl=1');
    $sessionId = $proxy->login((object)array('username' => 'user', 'apiKey' => 'password'));
    $product = $proxy->catalogProductInfo($sessionId,'27','','','productId');
    $proxy->endSession($sessionId);

And for better reference see: http://devdocs.magento.com/guides/m1x/api/soap/catalog/catalogProduct/catalog_product.info.html

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.