在android中调用magento

时间:2014-09-19 12:43:25

标签: android magento soap ksoap2

我使用kso​​ap2 Android库通过SOAP调用Magento api。登录方法(获取sessionId)工作正常,但Call方法不接受其他参数。调用方法有三个参数: call(sessionId,resourcePath,数组参数)。我要调用的resourcePath是customer.list,其他参数是filter(email)。 Api文档是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);

使用此代码我成功获得了客户列表,但电子邮件过滤器不会适用。 提前谢谢!

2 个答案:

答案 0 :(得分:1)

更改并添加以下代码,如下所示

(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);

答案 1 :(得分:0)

嘿,问题是过滤器

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

调用客户列表

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