My code to access wcf web service is not working in android app:
on the top I have:
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://10.86.164.102/ABCWcfService/ABCWcfService.svc";
private static final String SOAP_ACTION = "http://tempuri.org/IABCWcfService/GetTitle";
private static final String METHOD_NAME = "GetTitle";
then in the method I have:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
String receivedString = result.toString();
}
catch (Exception e)
{
}
I found it breaks into exception after line androidHttpTransport.call(SOAP_ACTION, envelope); but the e has value null.
I use the same code in a Java project to access the same wcf web service, and it works fine.
I did add:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="8" />
<application>
....
</application>
in the manifest file, before the application section. But still does not work.
I have read a lot of different threads over the internet. None of them solve my problem. Anyone got better suggestion? Thank you.
The web service is running on the same machine as the android app.