Working with Message Builders and Formatters
When a message is received by WSO2 DSS, the receiving transport selects a message builder based on the content type of the message. The selected builder will then be used to process the message's raw payload data and convert it into SOAP. For example, if a JSON type message is received (contentType
set to 'application/json'), the message builder corresponding to JSON will convert the message into SOAP.
Conversely, when a message is sent from WSO2 DSS in response to an HTTP request, a message formatter corresponding to the accept header of the HTTP request is used to convert the outgoing message into the requested data format. For example, when a JSON type message is requested by an HTTP request (accept header set to 'application/json'), the message formatter corresponding to JSON will be used to build the outgoing message in JSON.
Message builders and message formatters are thereby used to support content negotiation.
Configuring message builders and formatters
Message builders and formatters are configured in the axis2.xml
 file stored in the <DSS_HOME>/repository/conf/axis2
 folder under the <messageBuilder>
 and <messageFormatters>
 sections. Given below are the default message builders and message formatters that are configured in the axis2.xml
 file.
Default message builders
Following are the default message builders configured in WSO2 DSS and the corresponding content types of incoming messages:
Â
Content type | Example | Message Builder |
---|---|---|
application/x-www-form-urlencoded | form | org.apache.axis2.builder.XFormURLEncodedBuilder |
multipart/form-data | form | org.apache.axis2.builder.MultipartFormDataBuilder |
application/xml | Plain old xml | org.apache.axis2.builder.ApplicationXMLBuilder |
application/json | JSON (mapped notation) | org.apache.axis2.json.gson.JsonBuilder |
application/json/badgerfish | JSON (badgerfish notation) | org.apache.axis2.json.JSONBadgerfishOMBuilder |
text/javascript | Json payload | org.apache.axis2.json.gson.JsonBuilder |
Â
Default message formatters
Following are the default message formatters configured in WSO2 DSS and the corresponding accept headers used for outgoing messages.
Accept type | Example | Message Formatters |
---|---|---|
application/x-www-form-urlencoded | forms | org.apache.axis2.transport.http.XFormURLEncodedFormatter |
multipart/form-data | forms | org.apache.axis2.transport.http.MultipartFormDataFormatter |
application/xml | Plain old xml | org.apache.axis2.transport.http.ApplicationXMLFormatter |
text/xml | Soap envelope | org.apache.axis2.transport.http.SOAPMessageFormatter |
application/soap+xml | Soap envelope | org.apache.axis2.transport.http.SOAPMessageFormatter |
application/json | JSON (mapped notation) | org.apache.axis2.json.gson.JsonFormatter |
application/json/badgerfish | JSON (badgerfish notation) | org.apache.axis2.json.JSONBadgerfishMessageFormatter |
text/javascript | Json payload | org.apache.axis2.json.gson.JsonFormatter |