Class TransportUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.axiom.om.OMElementcreateDocumentElement(String contentType, Builder builder, MessageContext msgContext, InputStream inStream) static org.apache.axiom.om.OMElementcreateDocumentElement(String contentType, MessageContext msgContext, InputStream inStream) static org.apache.axiom.soap.SOAPEnvelopecreateSOAPEnvelope(org.apache.axiom.om.OMElement documentElement) static org.apache.axiom.soap.SOAPEnvelopecreateSOAPMessage(MessageContext msgContext) static org.apache.axiom.soap.SOAPEnvelopecreateSOAPMessage(MessageContext msgContext, boolean detach) This method will create a SOAPEnvelope based on the InputStream stored on the MessageContext.static org.apache.axiom.soap.SOAPEnvelopecreateSOAPMessage(MessageContext msgContext, InputStream inStream, String contentType) Objective of this method is to capture the SOAPEnvelope creation logic and make it a common for all the transports and to in/out flows.static org.apache.axiom.soap.SOAPEnvelopecreateSOAPMessage(MessageContext msgContext, InputStream inStream, String contentType, Builder builder) Objective of this method is to capture the SOAPEnvelope creation logic and make it a common for all the transports and to in/out flows.static voiddeleteAttachments(MessageContext msgContext) Clean up cached attachment filestatic voiddetachInputStream(MessageContext msgContext) Prepare the message in the given message context so that the underlying input stream can be closed.static booleandoWriteMTOM(MessageContext msgContext) Checks whether MTOM needs to be enabled for the message represented by the msgContext.static booleandoWriteSwA(MessageContext msgContext) Checks whether SOAP With Attachments (SwA) needs to be enabled for the message represented by the msgContext.static StringgetCharSetEncoding(String contentType) Extracts and returns the character set encoding from the Content-type header Example: Content-Type: text/xml; charset=utf-8static StringgetCharSetEncoding(MessageContext msgContext) Utility method to query CharSetEncoding.static StringgetContentType(String contentType, MessageContext msgContext) static booleanisDoingREST(MessageContext msgContext) static booleanisResponseWritten(MessageContext messageContext) This is a helper method to get the response written flag from the RequestResponseTransport instance.static voidprocessContentTypeForAction(String contentType, MessageContext msgContext) static voidsetResponseWritten(MessageContext messageContext, boolean responseWritten) This is a helper method to set the response written flag on the RequestResponseTransport instance.static voidwriteMessage(MessageContext msgContext, OutputStream out)
-
Constructor Details
-
TransportUtils
public TransportUtils()
-
-
Method Details
-
createSOAPMessage
public static org.apache.axiom.soap.SOAPEnvelope createSOAPMessage(MessageContext msgContext) throws AxisFault - Throws:
AxisFault
-
createSOAPMessage
public static org.apache.axiom.soap.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
-
createSOAPMessage
public static org.apache.axiom.soap.SOAPEnvelope createSOAPMessage(MessageContext msgContext, InputStream inStream, String contentType) throws AxisFault, org.apache.axiom.om.OMException, XMLStreamException, FactoryConfigurationError Objective of this method is to capture the SOAPEnvelope creation logic and make it a common for all the transports and to in/out flows.- Parameters:
msgContext- message contextinStream- input streamcontentType- content type of the message- Returns:
- the SOAPEnvelope
- Throws:
AxisFault- if an error occursorg.apache.axiom.om.OMException- if the xml is invalidXMLStreamException- if the stream is invalidFactoryConfigurationError
-
createSOAPMessage
public static org.apache.axiom.soap.SOAPEnvelope createSOAPMessage(MessageContext msgContext, InputStream inStream, String contentType, Builder builder) throws AxisFault, org.apache.axiom.om.OMException, XMLStreamException, FactoryConfigurationError Objective of this method is to capture the SOAPEnvelope creation logic and make it a common for all the transports and to in/out flows.- Parameters:
msgContext- message contextinStream- input streamcontentType- content type of the messagebuilder- the builder to be used- Returns:
- the SOAPEnvelope
- Throws:
AxisFault- if an error occursorg.apache.axiom.om.OMException- if the xml is invalidXMLStreamException- if the stream is invalidFactoryConfigurationError
-
createSOAPEnvelope
public static org.apache.axiom.soap.SOAPEnvelope createSOAPEnvelope(org.apache.axiom.om.OMElement documentElement) -
createDocumentElement
public static org.apache.axiom.om.OMElement createDocumentElement(String contentType, MessageContext msgContext, InputStream inStream) throws AxisFault, XMLStreamException - Throws:
AxisFaultXMLStreamException
-
createDocumentElement
public static org.apache.axiom.om.OMElement createDocumentElement(String contentType, Builder builder, MessageContext msgContext, InputStream inStream) throws AxisFault, XMLStreamException - Throws:
AxisFaultXMLStreamException
-
getContentType
-
getCharSetEncoding
Extracts and returns the character set encoding from the Content-type header Example: Content-Type: text/xml; charset=utf-8- Parameters:
contentType-
-
writeMessage
- Throws:
AxisFault
-
processContentTypeForAction
-
isResponseWritten
This is a helper method to get the response written flag from the RequestResponseTransport instance. -
setResponseWritten
This is a helper method to set the response written flag on the RequestResponseTransport instance. -
deleteAttachments
Clean up cached attachment file- Parameters:
msgContext-
-
detachInputStream
Prepare the message in the given message context so that the underlying input stream can be closed.- Parameters:
msgContext-- Throws:
AxisFault
-
doWriteMTOM
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
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
-
getCharSetEncoding
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
-