Skip filter to retrieve a specific set of customer list from magento using the ksoap library in JAVA

I am using the SOAP API to retrieve data from a magento server.
I want to get a list of clients, and I want to pass a filter to get a specific list of clients. I use hashMap, but it throws a Serialization exception.

My code is like

{request = new SoapObject(NAMESPACE, "customerCustomerInfo"); request.addProperty("sessionId", sessionId); HashMap<String, Object> filter=new HashMap<String, Object>(); filter.put("customer_id", condition); request.addProperty("filters", filter);} 

I also used jsonobject, a simple Arraylist, but it raised the same exception.

+4
source share
2 answers

You can try changing the “HashMap” to “HashTable” and registering “MarshalHashtable” in your envelope.

how

 SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11); androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.debug=true; (new MarshalHashtable()).register(env); // filter Hashtable <String, String> filter=new Hashtable<String, String>(); filter.put("customer_id", "1"); request.addProperty("filter", filter); 

got it sugestion from

"Use an array of parameters to create a query" in

https://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks

+3
source

@Ricardo's answer is correct, and it helped me, but I am posting this complete code to those who are still confused. The code below will indicate the orders of a specific customer.

 SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11); env.dotNet = false; env.xsd = SoapSerializationEnvelope.XSD; env.enc = SoapSerializationEnvelope.ENC; Hashtable hashtable = new Hashtable(); hashtable.put("customer_id", 17); SoapObject request = new SoapObject(NAMESPACE, "salesOrderList"); request.addProperty("filters", hashtable); request.addProperty("sessionId", sessionId); env.setOutputSoapObject(request); HTttpTransportSE transportSE = new HttpTransportSE(URL); transportSE.debug=true; (new MarshalHashtable()).register(env); 
+1
source

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


All Articles