在android中调用magento

问题描述 投票:0回答:2

我正在使用 ksoap2 Android 库通过 SOAP 调用 Magento api。登录方法(获取 sessionId)工作正常,但调用方法不接受额外的参数。 Call方法有3个参数: 调用(会话 ID、资源路径、数组参数)。我想调用的resourcePath是customer.list,附加参数是filter(email)。 API 文档位于这里

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

使用此代码,我成功获取了客户列表,但电子邮件过滤器不适用。 预先感谢!

android magento soap ksoap2 magento-soap-api
2个回答
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);

0
投票

嘿,过滤器有问题

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

致电客户名单,如

$result = $client->call($session, 'customer.list', $filters);
© www.soinside.com 2019 - 2024. All rights reserved.