A Java service was created that coverts a stream to bytes prior to my having started work in the webMethods environment. Unfortunetly converting those bytes back to a stream does not exist.
We currently have a service in place that will receive an HTTP request that contains two headers and a stream. For debugging purposes the stream to bytes was created in the past to convert the stream to bytes and saving the pipeline to a file so that the developers would be able to debug this service. I cannot figure for the life of me how the previous developer used that service.
So hear I am trying to create the code to convert the bytes back to a stream so that I can pass that stream on to create mimeobjects from it. What follows is the code that converts the stream to bytes:
InputStream in = null;
String errorMessage = “”;
// pipeline
IDataHashCursor pipelineCursor = pipeline.getHashCursor();
if ( pipelineCursor.first( “content” ) )
{
Object o = pipelineCursor.getValue();
if (o == null || !(o instanceof InputStream))
{
IDataHashCursor pipelineCursor_1 = pipeline.getHashCursor();
pipelineCursor_1.last();
pipelineCursor_1.insertAfter( “errorMessage”, “No input stream”);
pipelineCursor_1.destroy();
return;
} // End if
in = (InputStream)pipelineCursor.getValue();
}
pipelineCursor.destroy();
int i = 0;
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
while ((i = in.read()) >= 0) {
out.write(i);
} // End while
} // End try
catch (IOException ioerr) {
IDataHashCursor pipelineCursor_1 = pipeline.getHashCursor();
pipelineCursor_1.last();
pipelineCursor_1.insertAfter( “errorMessage”, ioerr.toString());
pipelineCursor_1.destroy();
return;
} // End catch
// pipeline
IDataHashCursor pipelineCursor_1 = pipeline.getHashCursor();
pipelineCursor_1.last();
pipelineCursor_1.insertAfter( “bytes”, out.toByteArray());
pipelineCursor_1.destroy();
#webMethods#Integration-Server-and-ESB#Flow-and-Java-services