kasto_manche
kasto_manche

Reputation: 210

How to send filter parameters to navision web service from android using ksoap2?

How to pass filter for navision web service from android using ksoap2? I am getting all the data and the filter passed is not working. What is the correct way to pass filter?

I tried

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);

    envelope.dotNet = true;
    request.addProperty("City_Code","2");

I want to get the Towns whose City_Code is 2, but above code returns all the towns.

I also tried

    HashMap<String, String> filter = new HashMap<String, String>();

    filter.put("Field", "City_Code");
    filter.put("Criteria", "2");
    request.addProperty("Town_List_Filter",filter);

    envelope.setOutputSoapObject(request)

With this code I am getting no response.

Upvotes: 0

Views: 693

Answers (1)

Born To Win
Born To Win

Reputation: 3329

Try this.

You have to just create an simple array of your key and value and just simple pass as parameter to request.addproperty method.

         try {

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.implicitTypes = true;
            envelope.setAddAdornments(false);
            envelope.dotNet = true;
            envelope.encodingStyle = SoapSerializationEnvelope.XSD;
            SoapObject request = new SoapObject("", METHOD_NAME);    //Your method name 

            for (int i = 0; i < key.length; i++) {
                request.addProperty(key[i], value[i]);       //your key and values as an array
            }

            envelope.setOutputSoapObject(request);

            HttpTransportSE ht = new HttpTransportSE(URL);      //Your URL
            ht.debug = true;
            ht.call(SOAP_ACTION, envelope);       //Your Soap_Action 
            s = ht.responseDump;

            Log.d(TAG, "HTTP REQUEST:\n" + ht.requestDump);
            Log.d(TAG, "HTTP RESPONSE:\n" + s);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return s;

Hope it will works for you.

Upvotes: 0

Related Questions