Tag Archives: parameters passed as null

Consuming webservice from Android

I was trying to consume .Net webservices from Android application using ksoap2-for-android sdk, I was getting proper response when there are no parameters to pass. When I’m trying to pass parameters, I was not succeeded. I seached lots of forums, there are so many suggestions, after implementing them I was able to send parameters and get the response correctly.

This was my code:

private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String strURL = "http://w3schools.com/webservices/tempconvert.asmx";
TextView tv;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
tv =(TextView)findViewById(R.id.TextView01);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
AndroidHttpTransport transport ;
transport = new AndroidHttpTransport(strURL);
transport.setXmlVersionTag(/"<?xml version=/"1.0/" encoding=/"utf-8/"?/>");
transport.call(SOAP_ACTION, envelope);
SoapPrimitive resultString = (SoapPrimitive)envelope.getResponse();
tv.setText("Status:" + resultString.toString());
catch(Exception e){

To resolve the issue regarding Outbound parameters passed as null, the following suggestions were been provided:

1. If you are using IE set to Access data across domains to enabled
2. change addProperty(“Temperature”,”23.5″); to addProperty(“arg0″,”23.5”); even without implementing this suggestion also I was able to connect
3. Set the encoding style for the envelope.
4. Set the boolean dotnet if you are connecting .Net web service
5. There is also a workaround to use ksoap and java.net tools combined to connect to webservice with the entire soap body specified.
6. Set the Content-Type
7. And if you are connecting a webservice on your localmachine, then provide the ipaddress rather than localhost/webservicename like
8. Sometimes UAC blocks the connection, try running eclipse in administrator mode.

These are the suggestions kept together any of them may work for you..

Hope this saves someone’s day