android - 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;
}
解决方案
您确定以下是有效的肥皂服务 URL 吗?
String URL = "http://www.example.com/Servicios_web/WebService.asmx";
你有调用失败的堆栈跟踪吗?
推荐阅读
- swift - Swift 递归编码自定义类数据结构
- python - 其显示错误“浮动”对象不能解释为整数
- c++ - 如何在 C++ 中的两个函数之间添加水平空间?
- mysql - myisampack 无法访问数据文件
- python - 按另一个列表中子字符串的索引对列表中的项目进行排序
- rust - 第二次迭代后匹配臂不触发条件
- python - 如何在 Python 中创建并返回 T 类型的新实例
- pine-script - PineScript - 来自另一个指标的输入源
- sql - 如何记录我的投资组合项目的 SQL 查询?
- rust - 尽管 Rocket 和 serde 都被列为依赖项,但无法使用 Rocket::serde::json::Json