Configuring for Response (Outbound or Fault) Flow
You can configure outbound messages sent from a service by configuring the following:
Add the following code.
To set a 'Basic' context parameter:
//Create a Mutable callbackContext (Response flow) from the original RequestContext MutableCallbackContext originalCallbackContext = (MutableCallbackContext) originalRequestContext.createCallbackContext(); originalCallbackContext.setParameter("bookCategoryCP", String.class, "Classic");
The value Classic is set for the HTTP Header bookCategory (corresponding to the context parameter bookCategoryCP) in the outgoing REST Response.
To set a context parameter 'Bag' :
//Create a Mutable callbackContext (Response flow) from the original RequestContext MutableCallbackContext originalCallbackContext = (MutableCallbackContext) originalRequestContext.createCallbackContext(); HashMap<String, String> responseHeadersAllCP_service_map = new HashMap<String, String>(); responseHeadersAllCP_service_map.put("bookAuthor", "Harper Lee"); responseHeadersAllCP_service_map.put("bookPublishYear", "1960"); originalCallbackContext.setParameter("responseHeadersAllCP", Map.class, responseHeadersAllCP_service_map);
The contents of the HashMap responseHeadersAllCP_service_map will be set as HTTP Headers (user-defined, corresponding to context parameter responseHeadersAllCP) in the outgoing REST Response. Setting native HTTP Headers is not permitted.
Copyright © Cloud Software Group, Inc. All rights reserved.