issues calling webservice using ksoap2

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

issues calling webservice using ksoap2

Postby hans1 » Sun Jun 13, 2010 7:16 pm

Hi ,

I am new to Android development, I am trying to consume some webservice. I am always receiving response as "0", I am passing parameters.

Here is the code:

private static final String SOAP_ACTION = "http://www.webserviceX.NET/ConvertTemp";
private static final String METHOD_NAME = "ConvertTemp";
private static final String NAMESPACE = "http://webservicex.net/";
private static final String strURL = "http://www.webservicex.net/ConvertTemperature.asmx";
TextView tv;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv =(TextView)findViewById(R.id.TextView01);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//request.addProperty("Temperature","23.5");
request.addProperty("FromUnit", "degreeCelsius");
request.addProperty("ToUnit", "degreeFahrenheit");

PropertyInfo ppi = new PropertyInfo();
ppi.name="Temperature";
ppi.setValue("23.5");
ppi.setType(PropertyInfo.LONG_CLASS);
request.addProperty(ppi);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.encodingStyle=SoapSerializationEnvelope.ENC;

envelope.setOutputSoapObject(request);

AndroidHttpTransport transport ;
try
{
transport = new AndroidHttpTransport(strURL);
transport.debug=true;

transport.call(SOAP_ACTION, envelope);
SoapPrimitive resultString = (SoapPrimitive)envelope.getResponse();

tv.setText("Status:" + resultString.toString());

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




}

Can someone please help me out with this,

any help is appreciated.
hans1
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Jun 13, 2010 7:05 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 24 guests