Creating and Mapping Context Parameters
You can add context parameters to REST bindings in the Context Parameters section of the General tab.
- Procedure
- Navigate to the General tab > Context Parameters section of a Promoted Service or Reference.
- Add a new
Context Parameter. Select one or more Operations it applies to, the
Direction (
Input, Output or Fault
), and the Type (Basic
orBag
). For Basic Context Parameters, select a Definition, to describe the data type of the parameter.For instance,
bookNameCP
is aBasic
string context parameter that applies to the input flow of thegetBookList
operation. The namebookNameCP
is used for context parameter mapping in the next step, and is also referred to by IT Implementation. - Navigate to the
Bindings tab in the
REST Binding Context Parameter Mapping section and specify the HTTP header name in the
Header Name column.
- If the selected type is
Basic
, specify the HTTP header name in the Header Name column.The specified Header Name appears as an HTTP Header on the wire and the context Parameter name is used by Java IT for the Get and Set methods. For instance, the Basic string context parameterbookNameCP
is mapped to HTTP Header NamebookName
. That is, when a REST service binding intercepts a request, it retrieves the value of the HTTP HeaderbookName
and makes it available to IT Implementation as a value of context parameterbookNameCP
. - Generate the Java IT Implementation and add the following declaration to the Implementation class:
//org.osoa.sca.annotations.Context @Context //com.tibco.amf.platform.runtime.extension.context.ComponentContext public ComponentContext componentContext;