Web services gateway - The Filter interface

This topic gives more information on using each of the methods of the Filter interface. It supplements the information provided in the following Javadoc:

The Filter interface represents an object that is called during service invocation. You can register a bean that implements this interface to be called just before a request invocation, or just after a response is received for a particular service.

Gateway filters use the gateway WorkArea to get and set the gateway message context values. You get the gateway WorkArea partition from services:websphere/WSGW/workarea in the Java Naming and Directory Interface (JNDI), then use the UserWorkArea API to get and set data within the message context.

These are the two main methods you use for developing your filter:

Another important method that requires a specific value to be returned is getContextVersion().

If you want your filter to change the WSIFReponse and WSIFRequest messages, then note that changes to messages are only recognized if the setUpdatedRequest and setUpdatedResponse methods are called on the returned FilterAction object. The FilterAction object can also dictate whether or not to continue processing the message by calling the setContinueProcess method.

filterRequest method

The filterRequest method is called by the gateway Manager just before a request is sent to a target service. The return value from the method can indicate not to send the request.

The request parameter contains the request WSIFMessage. This consists of a set of named parts. Each part has a value that is encoded as an instance of an appropriate Java object. Filters can change the values of the Java object instances, but should not add or remove parts, or replace the values of parts with ones of a different type.

The Filter interface might decide not to proceed with the request. In that case the interface has three options:

If the request or response is modified, then it must be returned in an instance of the FilterAction class. If this return is not done, any change to the response is ignored by the gateway.

filterResponse method

The filterResponse method is called by the gateway Manager just after a response is received from a target service. The response parameter contains the response or fault WSIFMessage. This message consists of a set of named parts.

Each part has a value that is encoded as an instance of an appropriate Java object. Filters can change the values of the Java object instances, but should not add or remove parts, or replace the values of parts with ones of a different type.

The Filter interface might decide not to proceed with the response. In that case the interface has three options:

If the response is modified, then it must be returned in an instance of the FilterAction class. If this return is not done, any change to the response is ignored by the gateway.

If the filter throws a FilterException exception, it is logged but the gateway continues to process other filters. If the filter throws a WSGWException exception, processing of the response is stopped.

See also Creating and returning a SOAP fault message from a filterResponse method.

getVersionString method

The getVersionString method returns a string form of the filter implementation version. The gateway uses this form when logging events relating to the filter so that the exact version of the filter implementation is known.

getContextVersion method

The getContextVersion method indicates the approach that this filter uses to access context information. To access the message context information for WebSphere Application Server Enterprise Version 5 or WebSphere Business Integration Server Foundation Version 5.1, implement this method to return the value: Filter.CONTEXT_VERSION_WORKAREA.

init method

The init method tells the filter that it is configured with the gateway. This method is called when you deploy a filter to the gateway.

destroy method

The destroy method tells the filter that it is no longer configured with the gateway. This method is called when you remove a filter from the gateway.


Related tasks
Writing a filter for the Web services gateway
Creating and returning a SOAP fault message from a filterResponse method
Related reference
Web services gateway - The gateway message context values



Searchable topic ID:   rwsg_pme_intfl
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/wsg/ref/rwsg_pme_intfl.html

Library | Support | Terms of Use | Feedback