0

次のメソッドはエラーを返しますsocket is not connected。Androidエミュレーターでlocalhost経由でPCに接続しようとしています。

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