我看到类似的问题,但我没有找到答案。 我正在使用ksoap2库与网络服务器连接,有时我得到了异常java.net.SocketTimeoutException:读取超时。在android中使用ksoap2的SocketTimeoutException
这里是我的代码:
SoapObject request = new SoapObject(NAMESPACE, method);
if (properties != null) {
for (PropertyInfo property : properties) {
request.addProperty(property);
}
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);;
HttpsTransportSE transport = new HttpsTransportSE(HOST, PORT, FILE, TIMEOUT);
transport.debug = true;
transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
try {
transport.call(NAMESPACE + "#" + soapAction, envelope);
Object res = (Object)envelope.getResponse();
return res;
} catch (Exception e) {
Log.e("WebService", e.toString());
return null;
}
我可以改变的地方超时套接字或我能做些什么?
你可以告诉我什么是envelop.bodyIn()函数吗?是不是超时异常没有发生的原因 –