Thank you for attention.
I have a problem using ksoap2 to call a web service via android.
I have a web service call function.
public String CallWebServiceFunction() { String WSDL_TARGET_NAMESPACE = "http://MyWeb.com/"; String SOAP_ADDRESS = "http://MyWeb.com/pvws.asmx"; String SOAP_ACTION = "http://MyWeb.com/SoapAction"; String OPERATION_NAME = "SoapAction"; SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME); PropertyInfo prop1 = new PropertyInfo(); prop1.setName("prop1"); prop1.setValue("1"); request.addProperty(prop1); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); Object response=null; try { httpTransport.call(SOAP_ACTION, envelope); response = envelope.getResponse(); } catch (Exception exception) { response=exception.toString(); } return response.toString(); }
When I use an emulator (or a real device) that uses API 16 or higher (Android 4.x) - everything is fine , the function receives the correct answer from webservice. But when I use an emulator (or real device) with API 7 (Android 2.x) - then I get an exception
"java.net.UnknownHostException: Host not resolved: MyWeb.com:80"
I use the same code in both cases, trying one after another - and get different results
Does anyone have any ideas?
UPD1 : permission section from my manifest
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
UPD2 : Hypothesis . I originally created my application for targetSdkVersion = 16. Therefore, I use multi-threaded code when I call webservice over the Internet. Maybe when it works with API7, the source code should not be multithreaded?
UPD3 . The hypothesis was wrong. Calling a webservice from the main thread throws the same exception.
But I noticed that when I run my project on another computer - it works correctly. Despite the fact that I use the same code.
source share