|
Date: Fri, 20th Mar, 2009 Level: Intermediate Reads: 2320 Comments: 3 | Login or register to post comments |
|
|
|
You need to follow the following steps in order to have JSON support in WSAS:
- Get the axis2-json jar and drop it into $WSAS_HOME/webapps/ROOT/WEB-INF/plugins/
- 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.
- 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"/>
- 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"/>
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
I did everything in this
When I use the Mapped convention I've got the followin error :
"Mapped formatted JSON with namespaces are not supported in Axis2. Make sure that your request doesn't include namespaces or use the Badgerfish convention".
Thanks in advance for any clues.
Hi krist_servansky
< 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" />
and
< 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 "/>
Stoped the server and started again, No errors found :)
But i'm i requesting it wrong ? The webservice call i'm making simple adds response=aplication/json
http://entitas-d.corp.turismodeportugal.pt:9763/services/Entity.EntityHttpSoap12Endpoint/getCAE?id=A&agent=f28c4324-0dc3-531b-98f1-d3c00cc6a36c&response=text/json
But the result still came in xml ( in Firefox and Chrome ). Any help ?
[1] http: //dist.wso2.org/maven2/org/apache/axis2/wso2/axis2-json/1.6.0-wso2v1/
[2] http: //dist.wso2.org/maven2/org/codehaus/jettison/wso2/jettison/1.0.1.wso2v1/
JSON output in the WSAS 3.1.0
Did I forget anything?