Search code examples
javaandroidweb-servicesksoap

Android kSOAP web service problem


I'm trying to invoke a public web service (w3schools.com/webservices/tempconvert.asmx) via kSOAP (downloaded and included the ".jar" directly from Google).

Here's my code:

// declarations

private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String METHOD_NAME = "CelsiusToFahrenheit";
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String URL = "http://216.128.29.26/webservices/tempconvert.asmx";

// code

try
{
   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
   SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
   HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

   request.addProperty("Celsius", "32");
   envelope.setOutputSoapObject(request);
   androidHttpTransport.call(SOAP_ACTION, envelope);

   Object result = envelope.getResponse();
}
catch(Exception e)
{
   e.printStackTrace();
}

Also, "AndroidManifest.xml" includes the permission to access the internet:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Also, my AVD can access the internet (tried it via the Browser app).

Can someone please help me? I've been trying this for about 6 hours now, and am still failing.

Thank you!


Solution

  • Not quite. I had it before (tried at least 5 different approaches). It didn't help. It was the API version. I had 12. It didn't work. I found somewhere that kSOAP works only with 8 and lower. Go figure :)

    I hope everyone who encountered this problem, will find this before they'll loose too much time with the 12 API.