Magento WS-I compatible v2 API WSDL-web service SOAP-ERROR: encoding: object does not have sessionId property

I am using the Magento v2 web service in WS-I compatibility mode

when trying to list a product i get exception

SOAP-ERROR: Encoding: object has no 'sessionId' property 

my code is below

 $proxy = new SoapClient('http://127.0.0.1/Magento1620/index.php/api/v2_soap?wsdl', array('trace' => 1, 'connection_timeout' => 120)); $sessionId = $proxy->login(array( 'username' => "zzc000", 'apiKey' => "zzc000" )); $filters = array( 'sku' => array('like'=>'zol%') ); $products = $proxy->catalogProductList($sessionId, $filters); 

Please help thanks

+6
source share
1 answer

In WS-I mode, there are a few minor differences when using the API.

  • The result of $ proxy-> login () is an object. You need to extract sessionId.
  • When calling $ proxy-> catalogProductList (), you need to provide the parameters in an associative array (as is the case with $ proxy-> login ()).

Please try the following:

 <?php try { error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); $proxy = new SoapClient('http://127.0.0.1/Magento1620/index.php/api/v2_soap?wsdl', array('trace' => 1, 'connection_timeout' => 120)); $session = $proxy->login(array( 'username' => "zzc000", 'apiKey' => "zzc000" )); $sessionId = $session->result; $filters = array( 'sku' => array('like'=>'zol%') ); $products = $proxy->catalogProductList(array("sessionId" => $sessionId, "filters" => $filters)); echo '<h1>Result</h1>'; echo '<pre>'; var_dump($products); echo '</pre>'; } catch (Exception $e) { echo '<h1>Error</h1>'; echo '<p>' . $e->getMessage() . '</p>'; } 

The same applies to other method calls for the WSA-compliant SOA API.

+19
source

Source: https://habr.com/ru/post/906010/


All Articles