use of org.apache.axis2.transport.http.ApplicationXMLFormatter in project wso2-synapse by wso2.
the class MessageUtils method getMessageFormatter.
/**
* This selects the formatter for a given message format based on the the content type of the received message.
* content-type to builder mapping can be specified through the Axis2.xml.
*
* @param msgContext axis2 MessageContext
* @return the formatter registered against the given content-type
*/
public static MessageFormatter getMessageFormatter(MessageContext msgContext) {
MessageFormatter messageFormatter = null;
String messageFormatString = getMessageFormatterProperty(msgContext);
messageFormatString = getContentTypeForFormatterSelection(messageFormatString, msgContext);
if (messageFormatString != null) {
messageFormatter = msgContext.getConfigurationContext().getAxisConfiguration().getMessageFormatter(messageFormatString);
if (LOG.isDebugEnabled()) {
LOG.debug("Message format is: " + messageFormatString + "; message formatter returned by AxisConfiguration: " + messageFormatter);
}
}
if (messageFormatter == null) {
messageFormatter = (MessageFormatter) msgContext.getProperty(Constants.Configuration.MESSAGE_FORMATTER);
if (messageFormatter != null) {
return messageFormatter;
}
}
if (messageFormatter == null) {
// If we are doing rest better default to Application/xml formatter
if (msgContext.isDoingREST()) {
String httpMethod = (String) msgContext.getProperty(Constants.Configuration.HTTP_METHOD);
if (Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)) {
return new XFormURLEncodedFormatter();
}
return new ApplicationXMLFormatter();
} else {
// Lets default to SOAP formatter
messageFormatter = new SOAPMessageFormatter();
}
}
return messageFormatter;
}
Aggregations