The Service Stream handler allows services to use raw streams when receiving requests from clients. The
OutputStream are the only required parameters.
Developing the service
When developing a service which uses the stream handler; the best way to implement the service is by using a static java method and the
java service engine.
The service definition
The service should always implement
serviceStreamInterface this provides the two IN parameters
outputStream. As always, you can override these parameters if necessary. The only OUT parameter is
contentType. This is used mainly for telling the
HttpServletResponse object what the response type is.
The service implementation
Reading the InputStream
The service implementation is simple; just like any other
Java service. The only difference is the main parameter
inputStream. Using a line of code:
You obtain a reference to the
InputStream object. When coming in from the event handler, this is the raw data posted from the browser.
Writing to the OutputStream
OutputStream in turn gets written back out to the client. This is an IN parameter which is referenced from the caller. Simply pull the
outputStream from the context:
Then write to the stream as you would normally. The content type is set by the caller before the stream is closed.
NOTE: Do NOT close the
OutputStream in your service; this is handled by the caller which is normally
Configuring the controller entry
- Be sure the
ServiceStreamHandleris set as one of the event handlers.
- Configure your events (mount points) to use this handler.