Context Parameters
A context parameter is a key-value pair passed to a service operation invocation. The values are populated by bindings, which map transport and binding headers to context parameters. Context parameters allow component developers to access transport and binding metadata that could affect the execution of an operation but which is not passed in the input, output, and fault messages defined by an abstract WSDL file.
A service may be supported on multiple types of transport bindings; each binding protocol specifies its own headers. For example, HTTP supports a body and headers that specify metadata that can be mapped to context parameters. The SOAP similarly defines a body and headers that are different than HTTP headers. The JMS protocol defines headers and allows developers to define application-specific properties. Typically, a client invoking a service will set some headers. For example, browsers usually set the HTTP Locale and Referrer headers.
Component implementations can read and set the values of context parameters and the values can be used to control service operation logic. The operation behavior thus changes according to the metadata. For example, consider a service that pays the agent that referred a customer to a website. To track the referrer on a SOAP/HTTP binding, you would specify a mapping from the HTTP Referrer header to a context parameter. If the service has a JMS binding, you would specify a mapping from a JMS message property named referencedBy to the same context parameter. When the incoming message is SOAP/HTTP, the HTTP Referrer header is copied into the context parameter and when a JMS message arrives, the referencedBy property is copied into the context parameter. The following table lists the header sources for each binding type.
Binding Type | Header Source |
---|---|
SOAP/HTTP | HTTP Transport Header, HTTP Context, TCP Context, SOAP Header, SOAP Fault |
SOAP/JMS | JMS Header, JMS Application Properties, SOAP Fault, SOAP Header |
JMS | JMS Header, JMS Application Properties |
- From: XXX Binding To: Context applies to inbound messages received on either a service ("in" part of "in-out" MEP) or a reference ("out|fault" part of "in-out" MEP)
- From: Context To: XXX Binding applies to outbound messages sent from either a service ("out|fault" part of "in-out" MEP) or a reference ("in" part of "in-out" MEP)
HTTP Context
JMS Header
import org.osoa.sca.annotations.Context; import com.tibco.amf.platform.runtime.extension.context.ComponentContext; /** * Use this property to access the context parameters. * Context parameters for this component are: * parameterName : DIRECTION */ @Context public ComponentContext componentContext;For each successive parameter, no error badge is added to the component. To update the list of context parameters in the comment, update the component implementation.
Methods defined on ComponentContext allow you to retrieve and set a RequestContext, which in turn has methods for retrieving and setting the context parameters.