Class TransportUtils


  • public class TransportUtils
    extends Object
    • Constructor Detail

      • TransportUtils

        public TransportUtils()
    • Method Detail

      • createSOAPMessage

        public static SOAPEnvelope createSOAPMessage​(MessageContext msgContext,
                                                     boolean detach)
                                              throws AxisFault
        This method will create a SOAPEnvelope based on the InputStream stored on the MessageContext. The 'detach' parameter controls whether or not the underlying DetachableInputStream is detached at the end of the method. Note, detaching the DetachableInputStream closes the underlying InputStream that is stored on the MessageContext.
        Throws:
        AxisFault
      • getCharSetEncoding

        public static String getCharSetEncoding​(String contentType)
        Extracts and returns the character set encoding from the Content-type header Example: Content-Type: text/xml; charset=utf-8
        Parameters:
        contentType -
      • processContentTypeForAction

        public static void processContentTypeForAction​(String contentType,
                                                       MessageContext msgContext)
      • isResponseWritten

        public static boolean isResponseWritten​(MessageContext messageContext)
        This is a helper method to get the response written flag from the RequestResponseTransport instance.
      • setResponseWritten

        public static void setResponseWritten​(MessageContext messageContext,
                                              boolean responseWritten)
        This is a helper method to set the response written flag on the RequestResponseTransport instance.
      • deleteAttachments

        public static void deleteAttachments​(MessageContext msgContext)
        Clean up cached attachment file
        Parameters:
        msgContext -
      • detachInputStream

        public static void detachInputStream​(MessageContext msgContext)
                                      throws AxisFault
        Prepare the message in the given message context so that the underlying input stream can be closed.
        Parameters:
        msgContext -
        Throws:
        AxisFault
      • doWriteMTOM

        public static boolean doWriteMTOM​(MessageContext msgContext)

        Checks whether MTOM needs to be enabled for the message represented by the msgContext. We check value assigned to the "enableMTOM" property either using the config files (axis2.xml, services.xml) or programatically. Programatic configuration is given priority. If the given value is "optional", MTOM will be enabled only if the incoming message was an MTOM message.

        Parameters:
        msgContext - the active MessageContext
        Returns:
        true if SwA needs to be enabled
      • doWriteSwA

        public static boolean doWriteSwA​(MessageContext msgContext)

        Checks whether SOAP With Attachments (SwA) needs to be enabled for the message represented by the msgContext. We check value assigned to the "enableSwA" property either using the config files (axis2.xml, services.xml) or programatically. Programatic configuration is given priority. If the given value is "optional", SwA will be enabled only if the incoming message was SwA type.

        Parameters:
        msgContext - the active MessageContext
        Returns:
        true if SwA needs to be enabled
      • isDoingREST

        public static boolean isDoingREST​(MessageContext msgContext)
      • getCharSetEncoding

        public static String getCharSetEncoding​(MessageContext msgContext)
        Utility method to query CharSetEncoding. First look in the MessageContext. If it's not there look in the OpContext. Use the defualt, if it's not given in either contexts.
        Parameters:
        msgContext - the active MessageContext
        Returns:
        String the CharSetEncoding