I'm new to android and I wanted to call wcf web service. I have found ksoap2 library and stated to apply the examples I found.The app failed with the following error message: java.net.SocketTimeoutException: Connection timeout. I had set user permission on the manafist file like that:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
I have also add the proxy, port, username and password from the emulator setting app-> wireless and network->mobile networks->Access Point Names. I have also added the following line from run configuration to additional emulator command line options:
-dns-server ns15.unitechost.in
But still it did not work, any help would be appreciated.
Update
I have configured the proxy setting from command line when starting AVD with the following command:
emulator -avd <avd_name> [-<option> [<value>]] ... [-<qemu args>]
Now I got the following exception:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT HTTP/1.1 500 Int...@11:1 in java.io.InputStreamReader@40531d48)
I have seen examples for consuming .asmx web service using ksoap2, can this be done on .svc web service as well? I'm using the attached code, I got from one if the examples:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class Main extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://tempuri.org/Istock/getCountry";
private static final String OPERATION_NAME = "getCountry";
private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
private static final String SOAP_ADDRESS = "http://127.0.0.1:8080/Service1.svc";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
setContentView(textView);
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
textView.setText(response.toString());
System.out.println(response.toString());
}
catch (Exception exception)
{
String exceptionStr=exception.toString();
textView.setText(exceptionStr);
System.out.println(exceptionStr);
Log.i("TAG",exceptionStr);
}
}
}
Thanks,