Problems while reading an InputStream
"Diego Ramirez Cardenas" <[email protected]> Wed, 10 Sep 2003 10:12:10 -0300
| Newsgroups | gmane.comp.java.enhydra.ksoap |
|---|---|
| Message-ID | <[email protected]> |
Hi there folks,
I'm having serious problems when I try to retrieve the response from a .NET Web Service. My MIDP application uses kSOAP to query my Web Service hosted on IIS 5.0. I have used the SoapRpcMethod attribute in my web method to make it RPC callable. Everything works fine in the emulator (I'm using JBuilder 9 Mobile Edition as IDE with JDK Wireless Toolkit 1.0.4).
But when I test it on the device (Motorola A388), my app locks when it try to read the last block of data in the InputStream. It never reaches the end of file (InputStream.read() = -1). I'm posting below an snippet of kSoap code where the app stops (Even if I disable the debug flag, it also stops when the XmlParser try to read the stream).
is = connection.openInputStream();
if (debug) {
bos = new ByteArrayOutputStream();
byte[] buf = new byte[256];
while (true) {
int rd = is.read(buf, 0, 256); -------> stops here when try to read the last block of data
if (rd == -1)
break;
bos.write(buf, 0, rd);
}
buf = bos.toByteArray();
responseDump = new String(buf);
is.close();
is = new ByteArrayInputStream(buf);
}
XmlPullParser xp = new KXmlParser();
xp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
xp.setInput (is, null); ---------> and stops here (inside setInput) if I disable the debug flag
I appreciate any help from you. My deadline is coming and I running out of ideas to solve this. Today I'll try to change the code to read the Content-Length in the header, and just read the exactly length of the stream. Without reaching the EOF, where resides my problem.
Thanks in advance.
Diego Ramirez Cardenas
CSIT Tecnologia e Serviços