Android的KSOAP2抛出SocketTimeoutException [英] Android KSOAP2 throws SocketTimeoutException

查看:775
本文介绍了Android的KSOAP2抛出SocketTimeoutException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用SOAP对象的上述库在我的Andr​​oid项目,以便连接到一个.NET Web服务。该应用程序是工作的罚款,直到我做了一些改变,也增加/减少的目标API。它开始抛出SocketTimeoutException并不会消失。

I have used the above library for SOAP objects in my Android project, in order to connect to a .NET web service. The application was working fine till I made some changes and also increased/decreased target API. It started throwing SocketTimeoutException and wont go away.

Android开发工具构建:v21.0.0-519525

任何帮助是AP preciated。

Any help is appreciated.

    private static final String NAMESPACE = "https://monitor.co.uk/";
    private static final String URL = "https://monitor.co.uk/WebService.asmx";

    private static final String GET_ID_METHOD = "GetId";
    private static final String GET_ID_SOAP_ACTION = "https://monitor.co.uk/GetId";
    public static String callGetIdWebService(String pass, String id, Context context)
    {
      String sRes = "";
      try 
      { 

        SoapObject request = new SoapObject(NAMESPACE, GET_ID_METHOD);

            PropertyInfo pi = new PropertyInfo();
            pi.setName("pass");
            pi.setValue(pass.toString());//"pass");// 
            pi.setType(pass.getClass());
            request.addProperty(pi);

            PropertyInfo pi2 = new PropertyInfo();
            pi2.setName("id");
            pi2.setValue(id.toString());
            pi2.setType(id.getClass());
            request.addProperty(pi2);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);  
            envelope.implicitTypes = true;

            HttpTransportSE httpTransport = new HttpTransportSE(URL);

            httpTransport.debug = true;

            httpTransport.call(GET_ID_SOAP_ACTION, envelope);
            Object response = envelope.getResponse();

            httpTransport.debug = true;
            if(response.toString().equals("-1"))
            {
                sRes = "No records";
            }
            else
            {
                sRes = response.toString();
            }
      } 

      catch (Exception e) 
      {
        e.printStackTrace();
        Log.i("EXCEPTION...", e.toString());

      }
      return sRes;
    }

日志下面猫:

01-28 17:39:34.213: W/System.err(16378): java.net.SocketTimeoutException
01-28 17:39:34.218: W/System.err(16378):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:130)
01-28 17:39:34.218: W/System.err(16378):    at com.example.notificationmanager.CreateNotificationActivity.callGetIdWebService(CreateNotificationActivity.java:94)
01-28 17:39:34.218: W/System.err(16378):    at com.example.notificationmanager.CreateNotificationActivity.createNotification(CreateNotificationActivity.java:37)
01-28 17:39:34.218: W/System.err(16378):    at java.lang.reflect.Method.invokeNative(Native Method)
01-28 17:39:34.218: W/System.err(16378):    at java.lang.reflect.Method.invoke(Method.java:511)
01-28 17:39:34.218: W/System.err(16378):    at android.view.View$1.onClick(View.java:3095)
01-28 17:39:34.218: W/System.err(16378):    at android.view.View.performClick(View.java:3627)
01-28 17:39:34.223: W/System.err(16378):    at android.view.View$PerformClick.run(View.java:14329)
01-28 17:39:34.223: W/System.err(16378):    at android.os.Handler.handleCallback(Handler.java:605)
01-28 17:39:34.223: W/System.err(16378):    at android.os.Handler.dispatchMessage(Handler.java:92)
01-28 17:39:34.223: W/System.err(16378):    at android.os.Looper.loop(Looper.java:137)
01-28 17:39:34.223: W/System.err(16378):    at android.app.ActivityThread.main(ActivityThread.java:4511)
01-28 17:39:34.223: W/System.err(16378):    at java.lang.reflect.Method.invokeNative(Native Method)
01-28 17:39:34.228: W/System.err(16378):    at java.lang.reflect.Method.invoke(Method.java:511)
01-28 17:39:34.228: W/System.err(16378):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-28 17:39:34.228: W/System.err(16378):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-28 17:39:34.228: W/System.err(16378):    at dalvik.system.NativeStart.main(Native Method)

Liaqat

Liaqat

推荐答案

得到这个固定后,我有另一对夫妇例外与应用程序和我的其他问题一些其他的一种民间正在进行的答复,并建议使用AsyncTask的。一旦得到了AsyncTask的工作,这个错误也走了。所以,你猜这是罚款承担问题是由与GUI活动做网络运行同样的问题引起的。

Got this fixed after I had another couple of Exceptions going on with the app and some other kind folk on my other question replied and suggested to use AsyncTask. Once got the AsyncTask working, this error also went away. So, guess this is fine to assume the issue was caused by the same problem with doing network operation on GUI activity.

你的帮助非常感谢。
Liaqat。

Many thanks for your assistance. Liaqat.

这篇关于Android的KSOAP2抛出SocketTimeoutException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆