2009/03/20
20 Mar, 2009

How to add JSON support to WSO2 WSAS

  • Kieth Chapman
  • - WSO2

You need to follow the following steps in order to have JSON support in WSAS:

  1. Get the axis2-json jar and drop it into $WSAS_HOME/webapps/ROOT/WEB-INF/plugins/
  2. Get the Jettison jar (Latest is 1.0.1) and drop it into $WSAS_HOME/webapps/ROOT/WEB-INF/plugins/

    Note : These jars need to be OSGI bundle jars. For simplicity I have attached OSGI bundles of this jars to this article. Please refer "How to build OSGi bundles using Maven Bundle Plugin" for details on how a OSGI bundle could be created from a jar.

  3. You need to make the underlining engine (Axis2) aware of the JSON related message builders. Add the following message builders to the messageBuilders section in the axis2.xml (found in $WSAS_HOME/conf/axis2.xml)
    <messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/>
    <messageBuilder contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
    <messageBuilder contentType="text/javascript" class="org.apache.axis2.json.JSONOMBuilder"/>
  4. You need to make the underlining engine (Axis2) aware of the JSON related Message Formatters. Add the following Message Formatters to the messageFormatters section in the axis2.xml which could be found in $WSAS_HOME/conf/axis2.xml
    <messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/>
    <messageFormatter contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
    <messageFormatter contentType="text/javascript" class="org.apache.axis2.json.JSONMessageFormatter"/>
  5. Note :  This instructs the underlining engine (Axis2) to treat messages with the contentType application/json, application/json/badgerfish and text/json as JSON messages.

     

Applies To

WSAS 3.0 and above

Author

Keith Chapman is a Senior Software Engineer at WSO2 - keith at wso2 dot com

 

About Author

  • Kieth Chapman
  • WSO2 Inc.