SOLVED - Stream Image through Web Service (RAW Datatype)

Posted by Admin on 12-Feb-2010 09:57

I have solved the issue and thought I should paste my code to help others getting stuck at this streaming issue.

My requirements were to read an image through webservice and display it on the browser. So in order to implement this I performed the following:

  1. Read image in chunks i.e. certain number of bytes at a time. I am reading 30 bytes at at time. These bytes are returned in a RAW data type (please see below for the code).
  2. Once I have the bytes I send these bytes to WEBSTREAM. On the client side user is given an option to save this file (the one being recieved through a web service) to a disk file.

/* Procedure invocation of OperationName . */
RUN OperationName IN hPortType(INPUT aConnectionHandle, INPUT fileHandle, INPUT chunkSize, OUTPUT RawDataTypeResult).

          
/* Receiving rest of the bytes in a LOOP */
DO WHILE LENGTH(RawDataTypeResult) NE ?:
            
     /* Sends stream to WEB Browser */               
     PUT {&WEBSTREAM} CONTROL RawDataTypeResult.
               
     /* Calling Web Service Operation */
     RUN OperationName IN hPortType(INPUT aConnectionHandle, INPUT fileHandle, INPUT chunkSize, OUTPUT RawDataTypeResult).
               
END.

The above code is sending the bytes being read to Web Browser through WEBSTREAM.

NOTE: If you are getting the error message discussed in my very first discussion, it is because the RAW type that you are using is not able to hold the number of bytes returned from the Web Service operation. How to solve this: Decrease the chunk size (i.e. the number of bytes to be read) and try again.

Hope this would help others with Image Streaming issue.


: ) <

Jatinder

All Replies

This thread is closed