Reputation: 186
i have done the following code in android for connecting to .net soap web service but it gives an errorr java.net.sockettimeoutexception : Socket not connected.
my code
package com.hello;
import android.app.Activity;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static final String METHOD_NAME = "HelloWorld";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://x.x.x.x/HelloWebService/HelloWebService.asmx";
public TextView mResult;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mResult=(TextView)findViewById(R.id.textView2);
try {
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.call(SOAP_ACTION, envelope);
String result=(String)envelope.getResponse();
mResult.setText("Content:" +result);
}
catch (Exception e)
{
mResult.setText(e.toString());
}
}
}
Help me please...!
Upvotes: 0
Views: 1344
Reputation: 4988
Although this may be a little late, this is what fixed it for me:
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);
Notice the second parameter, which is the timeout value.
I must admit tough, that i do not know the scale to go with this value, but I think this is measured in milliseconds.
Upvotes: 3