Cloud Application Integration (On-Premises) : Administering CloudStreams : Virtual Services : Important Considerations for REST Virtual Services : Changing the HTTP Method of a REST Virtual Service : 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 an IS service and invoke it in the virtual service's "In Sequence" step. This 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/cloudstreams/api/RuntimeFacade.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(ContextVariableType.ROUTING_METHOD.getName());

RuntimeFacade.setContextVariableValue(varName, "PUT", msgCtx );
}
}
Copyright © 2015- 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback