我正在开发一个Android应用程序,其中包含登录页面中的忘记密码概念。我正在为此应用程序使用Soap Web Service。
这是我的代码:
public void fncCallForgotPasswordService() {
String SOAP_ACTION = "http://example.org/ForgotPWD";
String METHOD_NAME = "ForgotPWD";;
String NAMESPACE = "http://example.org/";
String URL = "https://in.xyz.com/abcd.example/MethodExample.asmx";
try {
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("UID", strUserID);
Request.addProperty("CID", strCompID);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE transport = new HttpTransportSE(URL);
transport.call(SOAP_ACTION, soapEnvelope);
resultString = (SoapObject) soapEnvelope.getResponse();
resultString = (SoapObject) resultString.getProperty("Data");
resultString = (SoapObject) resultString.getProperty("Row");
strMessage = resultString.getPropertyAsString("Message");
if (resultString != null) {
Log.i("Message", strMessage);
}
Log.i("Result", "Result Celsius: " + resultString);
} catch (Exception ex) {
Log.e("Error", "Error: " + ex.getMessage());
}
}
Web服务正在提供新密码,但问题是我收到了一个例外情况
org.xmlpull.v1.XmlPullParserException: Invalid stream or encoding: java.io.IOException: BufferedInputStream is closed (position:START_DOCUMENT null@1:1) caused by: java.io.IOException: BufferedInputStream is closed
首次调用Web服务时,SoapObject“resultString”显示为null,并显示上述异常。但是当我连续第二次或第三次尝试时,不会抛出任何异常。只有在第一次调用Forgot Password Web服务时,它才会抛出上述异常。
另外,无论有没有例外,我都会在手机上收到新密码。
但我担心为什么会发生这种异常。
请帮助!
提前致谢。
答案 0 :(得分:0)
尝试自定义除非标准值之外的超时值:
HttpTransportSE androidHttpTransport = new HttpTransportSE(this.url,this.connectionTimeout)