File
File

Reputation: 181

calling magento in android

I'm using ksoap2 Android library to call Magento api trough SOAP. Login method (to get sessionId) works fine, but Call method won't accept additional arguments. Call method has three parameters: call(sessionId, resourcePath,array arguments). resourcePath I want to call is customer.list and additional paramteters is filter(email). Api documentation is here.

Hashtable<String, String> hashtable = new Hashtable<String, String>();
hashtable.put("email", "myemail");

SoapObject request = new SoapObject("urn:Magento", "call");
request.addProperty("resourcePath", "customer.list");
request.addProperty("sessionId", sessionId);
request.addProperty("args", hashtable);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
(new MarshalHashtable()).register(envelope);
envelope.dotNet = false;
envelope.xsd = SoapSerializationEnvelope.XSD;
envelope.enc = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(request);

HttpTransportSE transport = new HttpTransportSE(URL);
transport.debug = true;
transport.call("", envelope);

With this code i successfully get list of customers, but email filter won't apply. Thanks in advance!

Upvotes: 0

Views: 361

Answers (2)

Ankush Badlas
Ankush Badlas

Reputation: 111

Change and Add the following code as given below

(new MarshalHashtable()).register(envelope);
        Hashtable<String, String> hashtable = new Hashtable<String, String>();
        hashtable.put("email", "myemail");
 Vector<Hashtable<String, String>>aar2=new Vector<Hashtable<String, String>>();
        aar2.add(hashtable);
        parameter.addProperty("args", aar2);

Upvotes: 1

Amit Bera
Amit Bera

Reputation: 7611

hey it issue with filter

$filters = array(array('email' => array('eq'=>'myemail'))
);

call customer list like

$result = $client->call($session, 'customer.list', $filters);

Upvotes: 0

Related Questions