我在使用 android v4.0.3 的应用程序中使用 web 服务,但是当我到达
HttpTransportse
ShowsSocketTimeoutException
并没有得到响应时。相同的代码在 android.v.2.2 中完美运行
我在 logcat 中得到以下异常
05-10 11:18:38.245: W/System.err(849): java.net.SocketTimeoutException
05-10 11:18:38.255: W/System.err(849): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:130)
KSoap jar
---------
KSoap2 library android:2.5.2.jar
这是代码
public class busTravellDetailslistActivity extends Activity {
/** Called when the activity is first created. */
Button b;
EditText rteid,trvname,bustyp,deptm,arvtm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b=(Button) findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SoapObject request = new SoapObject("http://***********/WS2","TestRouteDataMobile");
//System.out.println("req count:"+request.getPropertyCount());
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE("http://**********/RouteSearchService.asmx");//namespace
try {
transport.call("http://***********/TestRouteDataMobile",envelope);
System.out.println("aftr call");
} catch (SocketTimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SoapObject response;
try {
response = (SoapObject)(envelope.getResponse());
Log.i("Response",response.toString());
} catch (SoapFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
}
});
}
}