0

以下方法返回错误socket is not connected。我正在尝试通过 android 模拟器中的 localhost 连接到我的电脑。

public class Service {
private static final String SOAP_ACTION = "http://tempuri.org/buscaProdutos";
private static final String METHOD_NAME = "buscaProdutos";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL =  "http://10.0.2.2:1727/Service1.asmx"; //localhost


public String GetRespostas(int valor) { //metod return string

    HttpParams httpParameters = new BasicHttpParams();

    HttpConnectionParams.setConnectionTimeout(httpParameters, 19000);

    int timeoutSocket = 9000;
    HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //conect 
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);


    try { 

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject result=(SoapObject)envelope.getResponse();

        return  result.getProperty(valor).toString();

    } catch (Exception e) {// e = "socket is not connected

        Log.d("erro", e.getMessage());
        return e.getMessage();

    }
}
}
4

1 回答 1

0

关闭防火墙或将访问权限设置为“1727”

于 2013-04-22T19:59:44.353 回答