JSON Support
This sample demonstrates the WSO2 Application Server's support for JSON, which comes from Apache Axis2.
For more information on how JSON works in Axis2, go to the following URLs:
- http://wso2.org/library/768 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
- http://axis.apache.org/axis2/java/core/docs/json_support.html
Building the sample
The JSON support sample is located in <AS_HOME>\Samples\JSON
directory.
For more information, see Building Axis2 Samples.
The generated service (JSONService.aar) gets copied to the <AS_HOME>/repository/deployment/server/axis2services
 directory automatically. If you start the WSO2 Application Server, and on the Main menu, under Services, click List the Deployed Services window will appear with the JSONService deployed.
The WSDL for the service should be viewable at: http://<host>:<port>/services/JSONService?wsdl
Running the client
Use the script run-client.sh
(in Linux/Solaris) or run-client.bat
file (in Windows) to invoke the client using following optional parameters:
-help (For help on available options) -e : Endpoint URL of the service. -ct {Content type to be used}        aj (application/json)        ajb (application/json/badgerfish)
For example,Â
./run-client.sh -ct ajb
In the JSON sample, an XML element is sent to the Application Server via the client.
<echo> Â Â <ns:value xmlns:ns="http://services.wsas.training.wso2.org">Hello JSON Service</ns:value> </echo>
You can change the http port  of the variable String epr = http://localhost:9763/services/JSONService
 in <AS_HOME>/samples/JSON/src/org/wso2/appserver/sample/json/client/JSONClient.java
and monitor the JSON object that is passed through to the Application Server, using a capturing tool such as TCP monitor.
The image above, depicts a JSON Object passing captured from the TCP monitor.