Configuring for Request (Outbound) Flow
You can configure outbound messages sent from a reference by configuring the following:
Add the following code.
To set a 'Basic' context parameter:
//Create a new Mutable requestContext from componentContext to set context parameters for Reference-side MutableRequestContext createMutableRequestContext = componentContext.createMutableRequestContext(); createMutableRequestContext.setParameter("bookNameCP", String.class, "How to Kill a Mockingbird");
The value How to Kill a Mockingbird is set for the HTTP Header bookName (corresponding to context parameter bookNameCP) in the outgoing REST Request.
To set a context parameter 'Bag':
//Create a new Mutable requestContext from componentContext to set context parameters for Reference-side MutableRequestContext createMutableRequestContext = componentContext.createMutableRequestContext(); HashMap<String, String> requestHeadersAllCP_reference_map = new HashMap<String, String>(); requestHeadersAllCP_reference_map.put("bookAuthor", "Harper Lee"); requestHeadersAllCP_reference_map.put("bookPublishYear", "1960"); createMutableRequestContext.setParameter("requestHeadersAllCP", Map.class, requestHeadersAllCP_reference_map);
The contents of the HashMap requestHeadersAllCP_reference_map are set as HTTP Headers (user-defined, corresponding to context parameter requestHeadersAllCP) in the outgoing REST Request.
Copyright © Cloud Software Group, Inc. All rights reserved.