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.

  • 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 Oct 21 '15 at 14:11
  • Yest i have that product with the id "27" and WS-I Compliance is enabled from configuration settings. – Arul James Oct 23 '15 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 Nov 13 '18 at 10:16
  • @zus. It's not my code. I didn't write this answer – Marius Nov 13 '18 at 11:03
  • @Marius really sorry, misunderstanding? – zus Nov 13 '18 at 11:24
3

Change the getProductInfo call to this

$product = $proxy->catalogProductInfo($sessionId->result , 27);
  • 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 Oct 23 '15 at 5:25
  • Above is the error what i am getting. what will be the problem? – Arul James Oct 23 '15 at 5:26
  • I don't know what the new problem is – Marius Oct 23 '15 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 Oct 23 '15 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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.