I tried building stubs and using java libraries to invoke web service using SOAP protocol. Of course it was a failure :) Then I found this kSOAP2, a third party library to send request objects and get the response object from the web service. At first it looked like a great solution but working with complex types was another show stopper. And in addition to that, the web service was receiving the element types as objects instead of primitive types, so I ended up getting an error code all the time.
My 3rd attempt was directly calling the web service through simple HttpUrlConnection sending an xml request. Of course the burden was parsing the xml properly and in a light weight so it won't kill my Android application.
Well it worked perfectly! and even faster!
The next R&D will be on calling existing application with wrappers. So this way it will be more secure.
URL url = new URL("http://..........");
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setDoInput(true);
http.setDoOutput(true);
http.setRequestMethod("POST");
http.setRequestProperty("Content-Type", "text/xml");
DataOutputStream stream = new DataOutputStream(http.getOutputStream());
//Build your xml request
//based on the wsdl
StringBuffer xmlInput = new StringBuffer();
xmlInput.append("");
xmlInput.append("
xmlInput.append("
xmlInput.append("
xmlInput.append("
xmlInput.append("
xmlInput.append("
xmlInput.append("");
stream.writeBytes(xmlInput.toString());
stream.flush();
stream.close();
http.connect();
int response = http.getResponseCode();
if(response == 200)
{
BufferedInputStream bis = new BufferedInputStream(http.getInputStream());
//you can use either SAXparser or DocumentBuilderFactory to parse your xml