Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Introducing the Sample

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, refer to the following external URLs:               

Building the Service

To build the samples you need Apache Ant build tool.

The steps are as follows.

1. Install and run the WSO2 Application Server. Refer to the Installation Guidefor instructions.

2. In a command prompt, switch to the sample directory.

For example, in Wndows, cd <AS_HOME>\samples\JSON

3. From there, type ant.

This will create the JSON service (JSONService.aar file) in <AS_HOME>/repository/deployment/server/axis2services directory. If you start the WSO2 Application Server, you can view the "JSONService" service on  "Deployed Services" window. (Main -> Services -> List).

The WSDL for the service should be viewable at: http://<host>:<port>/services/JSONService?wsdl

Running the Client

Use the script (in Linux) or run-client.bat file (in Windows) to invoke the client using following optional parameters.

Code Block
-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,  ./ -ct ajb

In the JSON sample, an XML element is sent to the Application Server via the client.

Code Block
   <ns:value xmlns:ns="">Hello JSON Service</ns:value>

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/ and monitor the JSON object that is passed through to the Application Server, using a capturing tool such as tcp monitor.

Image: JSON Object passing captured from tcp monitor.