Search code examples
javamagentoksoap

Pass filter to retrive specific set of customer list from magento using ksoap library in JAVA


I am using SOAP API to fetch data from magento server.
I want to fetch customer list and I want to pass filter to retrieve specific list of customers. I am using hashMap but it raises 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 have also used jsonobject , simple Arraylist , but its raised the same exception.


Solution

  • You can try to change "HashMap" to "HashTable", and register "MarshalHashtable" into your envelope.

    Like:

    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 this sugestion from

    "Use an array of parameters to create a request" at

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