CentraSite Documentation : Runtime Governance with CentraSite : Using Context Variables in Virtual Services : The API for Context Variables : pub.mediator.ctxvar:getContextVariable
pub.mediator.ctxvar:getContextVariable
Use this Java service to retrieve a context variable’s value and assign it to a pipeline variable. All parameter names are case-sensitive.
Parameter
Pipeline Type
Data Type
Description
Examples
MessageContext
in
Object ref
This object is inserted into the pipeline by Mediator.
N/A
varName
in
String
Context variable name (predefined or custom).

PROTOCOL_HEADERS
SOAP_HEADERS
mx:CUSTOM_VAR
serValue
out
Object ref
Java.io.serializable value. (Usually a string).
Notes on Getting and Setting the PROTOCOL_HEADERS and SOAP_HEADERS Variables
All context variable values are typed as either "string" or "int" except for the predefined context variables PROTOCOL_HEADERS and SOAP_HEADERS, which are of the type "IData". You can set/get values for PROTOCOL_HEADERS and SOAP_HEADERS in one of two ways:
*Set/get the entire structure.
To set the entire structure, you must:
*Set the varName parameter in pub.mediator.ctxvar:setContextVariable to PROTOCOL_HEADERS or SOAP_HEADERS.
*Use the method ISMediatorRuntimeFacade.setContextVariableValue().
To get the entire structure, you must:
*Set the varName parameter in pub.mediator.ctxvar:getContextVariable to PROTOCOL_HEADERS or SOAP_HEADERS.
*Use the method ISMediatorRuntimeFacade.getContextVariableValue().
If varName is set to PROTOCOL_HEADERS, you will get/set the entire IData structure containing all of the transport headers. The key is the transport header name (for example, Content-Type) and the value is a String. The IData object for PROTOCOL_HEADERS will contain a set of string values where each IData string key matches the header name in the transport headers map. The set of possible keys includes the HTTP v1.1 set of headers as well as any custom key-value pairs you might have defined.
If varName is set to SOAP_HEADERS, you will get/set the entire IData structure containing all of the SOAP headers in the SOAP envelope. The key is the array position starting with '0', and the value is an Axiom OMElement containing that SOAP header block.
Alternatively, you can set the varName parameter to address a specific element in the array. For example, setting it to PROTOCOL_HEADERS[Content-Type] would apply to the Content-Type transport header. Similarly, setting it to SOAP_HEADERS[0] would return a String representation of the first SOAP header block (as opposed to an Axiom OMElement).
*Set/get a nested value.
Set a nested value in one of the following ways:
*Set the varName parameter in pub.mediator.ctxvar:setContextVariable to PROTOCOL_HEADERS[arrayElement], where [arrayElement] refers to a specific element. For example, PROTOCOL_HEADERS[Content-Type] or SOAP_HEADERS[0] (to indicate the first array element in the set).
*Alternatively, use the method ISMediatorRuntimeFacade.setContextVariableValue(). You would use this method only if you are writing a Java service and you want to access it through the Java source code.
Get a nested value in one of the following ways:
*Set the varName parameter in pub.mediator.ctxvar:getContextVariable to PROTOCOL_HEADERS[arrayElement], where [arrayElement] refers to a specific element. For example, PROTOCOL_HEADERS[Content-Type] or SOAP_HEADERS[0] (to indicate the first array element in the set).
*Alternatively, use the method ISMediatorRuntimeFacade.getContextVariableValue(). You would use this method only if you are writing a Java service and you want to access it through the Java source code.
You can set/get a nested value inside PROTOCOL_HEADERS and SOAP_HEADERS via an additional keyName. In this case, the object reference will not be an IData object.
*For PROTOCOL_HEADERS, the keyName must match the transport header name in a case-sensitive manner (for example, PROTOCOL_HEADERS[Content-Type] or PROTOCOL_HEADERS[Authorization]). In this case, the Serializable value will be a string.
*For SOAP_HEADERS, the keyName must match the 0-based array element. If a request has a SOAP security header element (that is, </wsse:Security>), then it would be addressed as SOAP_HEADERS[0]. In this case, the element will be in its string format.
Copyright © 2005-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback