Class HeaderUtils

java.lang.Object
org.openehealth.ipf.platform.camel.ihe.ws.HeaderUtils

public abstract class HeaderUtils extends Object
Utilities for handling HTTP and SOAP headers in Web Service interactions.
Author:
Dmytro Rud
  • Method Details

    • processIncomingHeaders

      public static void processIncomingHeaders(Map<String,Object> messageContext, Message message)
    • processUserDefinedOutgoingHeaders

      public static void processUserDefinedOutgoingHeaders(Map<String,Object> messageContext, Message message, boolean isRequest)
    • getHeaders

      public static <T> T getHeaders(Map<String,Object> messageContext, String key, boolean useInputMessage, boolean needCreateWhenNotExist, Supplier<T> defaultValueFactory)
      Returns headers of the message represented by the given context.
      Type Parameters:
      T - type of headers' container.
      Parameters:
      messageContext - Web Service message context.
      key - key under which the headers reside in the message context.
      useInputMessage - whether input message should the used.
      needCreateWhenNotExist - whether the headers' map should be created when it does not exist.
      defaultValueFactory - factory for producing default values.
      Returns:
      either the map of HTTP headers as found in the message context, or a newly created map when none found, or null when creation of a new map is not allowed.
    • getIncomingHttpHeaders

      public static Map<String,String> getIncomingHttpHeaders(Message message)
      Extracts HTTP headers from a message.
      Parameters:
      message - Camel message.
      Returns:
      HTTP headers as a map from header name to header value.
    • getIncomingHttpHeaders

      public static Map<String,String> getIncomingHttpHeaders(Exchange exchange)
      Extracts HTTP headers from an incoming message.
      Parameters:
      exchange - Camel exchange containing the message.
      Returns:
      HTTP headers as a map from header name to header value.
    • getIncomingSoapHeaders

      public static Map<QName,Header> getIncomingSoapHeaders(Message message)
      Extracts SOAP headers from a message.
      Parameters:
      message - Camel message.
      Returns:
      SOAP headers as a map from header name to header value.
    • getIncomingSoapHeaders

      public static Map<QName,Header> getIncomingSoapHeaders(Exchange exchange)
      Extracts SOAP headers from an incoming message.
      Parameters:
      exchange - Camel exchange containing the message.
      Returns:
      SOAP headers as a map from header name to header value.
    • addOutgoingHttpHeaders

      public static void addOutgoingHttpHeaders(Message message, String... headers)
      Adds HTTP headers to a message.
      Parameters:
      message - Camel message.
      headers - varargs containing names and values of the headers to add, e.g. "X-MyHeader1", "12345", "X-MyHeader2", "tralala".
    • addOutgoingHttpHeaders

      public static void addOutgoingHttpHeaders(Exchange exchange, String... headers)
      Adds HTTP headers to an outgoing message.
      Parameters:
      exchange - Camel exchange containing the message.
      headers - varargs containing names and values of the headers to add, e.g. "X-MyHeader1", "12345", "X-MyHeader2", "tralala".
    • addOutgoingSoapHeaders

      public static void addOutgoingSoapHeaders(Message message, Header... headers)
      Adds SOAP headers to a message.
      Parameters:
      message - Camel message.
      headers - SOAP headers to add.
    • addOutgoingSoapHeaders

      public static void addOutgoingSoapHeaders(Exchange exchange, Header... headers)
      Adds SOAP headers to an outgoing message.
      Parameters:
      exchange - Camel exchange containing the message.
      headers - SOAP headers to add.