CentraSite Documentation : Runtime Governance with CentraSite : Important Considerations when Configuring REST or XML Virtual Services : Changing the HTTP Method of a REST or XML Request : Changing HTTP Methods in Requests Dynamically using a Context Variable
Changing HTTP Methods in Requests Dynamically using a Context Variable
Alternatively, instead of changing an HTTP method explicitly (statically) to PUT, POST, GET or DELETE, you can change the HTTP method to the value of a predefined context variable (ROUTING_METHOD) that dynamically resolves to a different HTTP method (PUT, POST, GET or DELETE, as appropriate).
To change the HTTP method dynamically, you create a webMethods IS service and invoke it in the virtual service's Invoke webMethods IS Service action. This webMethods IS service should reference the predefined context variable ROUTING_METHOD (see The Predefined Context Variables). To set the value of ROUTING_METHOD, use the setContextVariableValue method, which is defined in the following class:
com/softwareag/mediator/api/MediatorRuntimeFacade.java
For example:
public static final void updateHttpMethod(IData pipeline)
throws ServiceException {
 
String mcKey = “Message Context”;
 
Object obj = IDataUtil.get(pipeline.getCursor(), mcKey);
if (obj!=null && obj instanceof
org.apache.axis2.context.MessageContext) {
 
MessageContext msgCtx = (MessageContext) obj;
 
QName varName =
new QName(MediatorContextVariableType.ROUTING_METHOD.getName());
 
MediatorRuntimeFacade.setContextVariableValue(varName, "PUT", msgCtx );
}
}
Copyright © Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback