Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

Skip to end of metadata
Go to start of metadata

Description

The Service Stream handler allows services to use raw streams when receiving requests from clients. The InputStream and 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 inputStream and 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.

services.xml

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

The 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 ServiceStreamHandler.java.

Code example

OagisServices.java

Configuring the controller entry

  1. Be sure the ServiceStreamHandler is set as one of the event handlers.
  2. Configure your events (mount points) to use this handler.
controller.xml
  • No labels