One of the clients would be sending large XML in the form of zipped object over MQ. I need to retrieve certain information from the xml. I was able to read the zipped xml using gZipInputStream. However instead of reading the xml and constructing a string, I want to pass the GZipInputStream to xmlStringToXMLNode. Once I can get the node, i will be able to use NodeIterator services for large XML handling.
Below snapshot of the code has commented the byte-by-byte read, which works absolutely fine. However if I pass gZipInputStream to xmlStringToXMLNode, I don’t get any error, but looks like it returns empty node.
IDataCursor pipelineCursor = pipeline.getCursor();
Object obj = IDataUtil.get( pipelineCursor, "in" );
pipelineCursor.destroy();
Object node = null;
StringBuffer out = new StringBuffer();
String value = null;
try {
byte[] byteArray = (byte[])obj;
GZIPInputStream gZipInputStream = new GZIPInputStream(new ByteArrayInputStream(byteArray));
/* byte[] strBufInBytes = new byte[1];
int bytesRead = gZipInputStream.read(strBufInBytes);
while(bytesRead != -1)
{
value = new String(strBufInBytes);
out.append(value);
bytesRead = gZipInputStream.read(strBufInBytes);
}
*/
IData input = IDataFactory.create();
IDataCursor inputCursor = input.getCursor();
IDataUtil.put( inputCursor, "$filestream", gZipInputStream );
inputCursor.destroy();
// output
IData output = IDataFactory.create();
output = Service.doInvoke( "pub.xml", "xmlStringToXMLNode", input );
IDataCursor outputCursor = output.getCursor();
node = IDataUtil.get( outputCursor, "node" );
outputCursor.destroy();
gZipInputStream.close();
}
catch(Exception e) {
throw (ServiceException) e;
}
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, "out", node);
pipelineCursor_1.destroy();
Any pointers/thoughts on what might be wrong?