Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento WS-I compliant v2 API WSDL web service SOAP-ERROR: Encoding: object has no 'sessionId' property

Tags:

magento

I'm using Magento v2 web service in WS-I compliant mode

when try to list product i get exception

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

my code is listed 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

like image 242
ANU Ads Audience Connector Avatar asked Jan 15 '12 04:01

ANU Ads Audience Connector


1 Answers

In WS-I mode, there are some minor differences in using the API.

  1. The result of $proxy->login() is an object. You need to extract the sessionId.
  2. When calling $proxy->catalogProductList(), you need to provide the parameters in an associative array (just like you did with $proxy->login()).

Please try this:

<?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 WS-I compliant v2 SOAP API.

like image 103
Matthias Zeis Avatar answered Sep 19 '22 15:09

Matthias Zeis