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!
i just tried my own code (which only differs in the webservice its trying con use) with api version 10 and ksoap2 and it still works as expected.
The problem is that you are doing a network call on the main thread and in API level 12 this is not allowed anymore. You just have to move the ksoap2 call to an AsyncTask or so. This problem would occur with anything doing network access by the way. It is an enforced strict mode check.
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.
seems like your doing the same tutorial as i am. http://www.vimeo.com/9633556
it seems like you are missing
envelope.dotNet = true;