首页 > 解决方案 > SocketTimeoutException:连接超时 Android ksoap

问题描述

我正在使用 ksoap 连接到 Web 服务,但是当我尝试从我的 Web 服务中获取值时出现问题。

我收到此错误异常 java.net.SocketTimeoutException: connect timed out

我已经检查了超时解决方案,但它仍然不起作用

此外,根据我的 WSDL 文件,我已经确保我的 METHOD、NAMESPACE 和 URL 是正确的。

您还有其他解决方案吗?

这是我的代码:

类 SegundoPlano 扩展 AsyncTask {

    @Override
    protected Void doInBackground(Void... voids) {
        logeo();
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {


        if (Re.compareTo("true") == 0) {
            //   try {
            Intent I = new Intent(getApplicationContext(), Menu.class);
            I.putExtra("folioen", Usuario);
            startActivity(I);

            // }
            // catch (Exception ex)
            //{
            //    Toast.makeText(MainActivity.this,ex.getMessage(), Toast.LENGTH_LONG);
            // }
        }
    }
}


private String logeo() {
    String mensaje;
    String URL = "http://www.example.com/Servicios_web/WebService.asmx";
    String metodo = "Acceso";
    String namespace = "http://tempuri.org/";
    String Accion = "http://tempuri.org/Access";
    try {
        SoapObject obtencion = new SoapObject(namespace, metodo);
        obtencion.addProperty("usuario", User);
        obtencion.addProperty("contra", Password);
        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        soapEnvelope.dotNet = true;
        soapEnvelope.setOutputSoapObject(obtencion);
        //HttpsTransportSE transporte = new KeepAliveHttpsTransportSE("192.168.4.38",440,"SERVIEPATH",7000);
        HttpTransportSE transporte = new HttpTransportSE(URL, 100000);
        transporte.call(Accion, soapEnvelope);
        SoapPrimitive resultado = (SoapPrimitive) soapEnvelope.getResponse();
        mensaje = resultado.toString();
        Re = resultado.toString();
    } catch (Exception ex) {
        mensaje = ex.getMessage();
    }

    return mensaje;
}

标签: androidsoapksoap

解决方案


您确定以下是有效的肥皂服务 URL 吗?

String URL = "http://www.example.com/Servicios_web/WebService.asmx";

你有调用失败的堆栈跟踪吗?


推荐阅读