CentraSite Documentation : Runtime Governance with CentraSite : Using Context Variables in Virtual Services : The API for Context Variables : Sample Flow Service: Getting a Context Variable Value
Sample Flow Service: Getting a Context Variable Value
This flow service gets the value of a custom context variable from a request. The service declares a context variable using the name defined in the pipeline variable customName (i.e., mx:COMP_TEST). It is hard-coded to store the predefined context variable SERVICE_NAME in this custom context variable name.
Figure 25. Step 1. Setting varName and customName
In this flow service, the following pipeline variables that are hard-coded as follows:
*varName is set to the predefined context variable SERVICE_NAME.
*customName is set to mx:COMP_TEST. SERVICE_NAME is stored in customName in the "Pipeline Out".
Figure 26. Step 2. Calling the pub.mediator.ctxvar:getContextVariable service
The call to pub.mediator.ctxvar:getContextVariable looks up the context variable value for the "Pipeline In" variable varName and sets the Serializable value in the output pipeline variable named serValue.
Figure 27. Step 3. Calling the pub.mediator.ctxvar:declareContextVariable service
The call to pub.mediator.ctxvar:declareContextVariable takes the serialized value we looked up for varName and assigns it to a newly declared custom context variable named ctxVar.
Figure 28. Step 4. Calling the pub.mediator.ctxvar:setContextVariable service
The call to pub.mediator.ctxvar:setContextVariable sets the context variable value back into MessageContext so it will be available for the rest of the service invocation steps.
Copyright © Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback