tags:

views:

63

answers:

2

I am new to android applications,I am using Ksoap2 to access .Net webservice and The call is executed just fine without parameters. But with parameters I am getting Empty. I followed all the steps provided in sites. I tried everything possible but no luck so far. I hope someone can help,

private static final String SOAP_ACTION = "http://www.agilelearning.com/GetProvincelist1"; private static final String METHOD_NAME = "GetProvincelist1 "; private static final String NAMESPACE = "http://www.agilelearning.com" ; private static final String URL = "http://192.168.1.24/Service.asmx";

//Method executed when Province is selected private OnItemSelectedListener selectListener = new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View v, int position, long id) { try { ArrayList districts=new ArrayList(); int Provinceid=position+1;//parent.getItemAtPosition(position).toString();
SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME1);
request1.addProperty("Provincename","East Province"); SoapSerializationEnvelope envelope1 = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope1.dotNet = true; envelope1.setOutputSoapObject(request1); HttpTransportSE at = new HttpTransportSE(URL); at.debug = true; at.setXmlVersionTag(""); at.call(SOAP_ACTION1, envelope1);
SoapObject rs = (SoapObject)envelope1.getResponse(); int count=rs.getPropertyCount(); for(int i=0;i aa;
aa = new ArrayAdapter(home1.this, android.R.layout.simple_spinner_item, districts); aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sd.setAdapter(aa); } catch(Exception ex) { MessageBox("No Districts found"); }

     }
A: 

Firstly, reformatting your code so it's more readable....

private static final String SOAP_ACTION = "http://www.agilelearning.com/GetProvincelist1";
private static final String METHOD_NAME = "GetProvincelist1";
private static final String NAMESPACE = "http://www.agilelearning.com";
private static final String URL = "http://192.168.1.24/Service.asmx";

//Method executed when Province is selected
private OnItemSelectedListener selectListener = new OnItemSelectedListener() {
    public void onItemSelected(AdapterView parent, View v, int position, long id) {
        try {
            ArrayList districts=new ArrayList();
            int Provinceid=position+1;
            //parent.getItemAtPosition(position).toString();
            SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME);
            request1.addProperty("Provincename","East Province");
            SoapSerializationEnvelope envelope1 = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope1.dotNet = true;
            envelope1.setOutputSoapObject(request1);
            HttpTransportSE at = new HttpTransportSE(URL);
            at.debug = true;
            at.setXmlVersionTag("");
            at.call(SOAP_ACTION, envelope1);

            SoapObject rs = (SoapObject)envelope1.getResponse();
            int count=rs.getPropertyCount();
            for(int i=0;i aa;
                aa = new ArrayAdapter(home1.this,
                                      android.R.layout.simple_spinner_item,
                                      districts);
            aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sd.setAdapter(aa);
        } catch(Exception ex) {
            MessageBox("No Districts found");
        }
    }
};

The issue is this line: envelope1.dotNet = true;

You can see in lines 404-407 of SoapSerializationEnvelope.java that it adds them. THe documentation says "Set this variable to true for compatibility with what seems to be the default encoding for .Net-Services. This feature is an extremely ugly hack. A much better option is to change the configuration of the .Net-Server to standard Soap Serialization!" Sounds like ksoap2 just hacked something in that seemed to work in one instance.

chad