调用WCF .net服务时,android studio中的Java.Net SocketTimeOutExection

问题描述 投票:0回答:1

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

 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(); 

但是在catch中给出异常res = java.net.SocketTimeOutException

如何解决这个问题请解释一下

java asp.net .net web-services
1个回答
0
投票

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

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

那是修复我的SocketTimeOutException的问题。

© www.soinside.com 2019 - 2024. All rights reserved.