Here we go ..
The first interesting thing that i came across was the ksoap2 library provided by google. Well, we need to know the purpose of this external jar file first ! My application had to connect to a web-service application hosted in a test server. For an android client to communicate with the web-server (.Net) we need add this ksoap2 library to our project properties (java build path).
download link : http://code.google.com/p/ksoap2-android/wiki/HowToUse?tm=2
The first noticeable thing with ksoap2 is to pick the right version from the google code page. I detected some issues with the 2.4 version which i downloaded initially. Later on, i downloaded the 2.5.5 from the download page and i had no example code to work on and the older example codes were not compatible with the latest version. So i decided to pick an intermediate version 2.5.2 from the google code page using tortoise svn from windows. (bcoz repo is maintained in svn).
Once you have obtained the 2.5.2, you can use this example code to work on.
public void GetResults()
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
//AndroidHttpTransport aht = new AndroidHttpTransport(URL);
HttpTransportSE aht = new HttpTransportSE(URL);
//SoapObject result = (SoapObject)soapEnvelope.bodyIn;
SoapObject result = (SoapObject)soapEnvelope.getResponse();
//SoapPrimitive result = (SoapPrimitive) soapEnvelope.getResponse();
//Object result = soapEnvelope.getResponse();
you may be wondering, what to import since ctrl+shift+O does not automatically fix the project settings. So here is the import list required :
See I faced a lot of issues with the import statements when i used the latest 2.5.5. So be careful with the import statements.
Now.. In the above code u might see somethings like NAMESPACE, METHOD_NAME ,URL etc. What are these ? and why are they important ??
this is the place where we are going to specify the webservice, the method exposed and its corresponding address.
private static final String SOAP_ACTION = "http://tempuri.org/MethodName";
private static final String METHOD_NAME = "MethodName";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://your_ip_where_service_running/Service1.asmx";
Many of you might ignore the last four lines of code, but believe me a small issue in the namespace took me 2 days to fix a certain deadly issue. When ever i passed a property / parameter to the web service - i was getting a null parameter there. I tried all the possible ways of sending the params, nothing worked. Finally found that the namespace name needs to end with a "/" else you will face with this kinda issues. There is one more notable thing here, we need to tell the soapEnvelope that this is going to communicate with a dotNet service. So soapenv.dotNet = true; is a compulsory thing !!
Once you have taken care about all these things, hope u can get it to work ;) more posts on its way !! If you have doubts post it here.