【问题标题】:Java.Net SocketTimeOutExection in android studio while calling WCF .net Service调用WCF .net服务时android studio中的Java.Net SocketTimeOutException
【发布时间】:2018-06-13 00:05:21
【问题描述】:

我正在尝试使用此代码调用网络服务

 public final String SOAP_ACTION = "http://tempuri.org/IServices/Login";
    public  final String OPERATION_NAME = "Login";
    public  final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
    public  final String SOAP_ADDRESS = "http://localhost:9198/Services.svc/soap";
    public  final int TIMEOUT = 3000000;

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
                    PropertyInfo pi = new PropertyInfo();
                    pi.setName("emailConn");
                    pi.setValue(emailConn);
                    pi.setType(String.class);
                    request.addProperty(pi);
                    pi = new PropertyInfo();
                    pi.setName("passwordConn");
                    pi.setValue(passwordConn);
                    pi.setType(String.class);
                    request.addProperty(pi);

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

                    envelope.setOutputSoapObject(request);

                    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS, TIMEOUT);
                    String response;
                    try {
                        httpTransport.call(SOAP_ACTION, envelope);
                        response = (String) envelope.getResponse();
                    } catch (Exception exception) {
                        response = exception.toString();
                    }
                    String res = response.toString(); 

但在捕获时给出异常 res = java.net.SocketTimeOutException

如何解决这个问题请解释

【问题讨论】:

    标签: java asp.net .net web-services


    【解决方案1】:

    如果您还没有,您需要在AndroidManifest.xml 中添加以下行:

    <uses-permission android:name="android.permission.INTERNET"/>
    

    这就是解决我的SocketTimeOutException的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      相关资源
      最近更新 更多