Jitu and I have been working on the JAX-WS JSON extension, which is a JAX-WS RI extension that lets you write one code and have it handle both SOAP and JSON requests. I just posted version 1.1 release of this extension.

The following code shows one way of deploying a JSON service:

public class MyService {

    public Book get(@WebParam(name="id") int id) {
        Book b = new Book();
        b.id = id;
        return b;

    public static final class Book {
        public int id = 1;
        public String title = "Java";

The JSON extension comes with the equivalent of "wsimport" tool, but in a JavaScript style. Once the service is deployed, JavaScript client can load the proxy code like this:

<script src="path/to/endpoint?js"></script>

With that, it can now make service invocations as shown in the following code. The call happens asynchronously, and upon the completion the callback is invoked with the response. This is a trivial example, but since this is built on top of JAXB, it can handle any JAXB annotated beans, just like your SOAP service does.

  function(r) {

The neat thing about this extension is that the system takes advantage of the schema information inside WSDL to produce JSON that looks more natural. I believe this is an unique feature not seen elsewhere in a simliar toolkit. This information is also used to generate the documentation page, so that developers writing client code can learn what format the request and the response are, without knowing anything about XML Schema. See the screenshot below to get some idea of how it looks like:


This is a part of the JAX-WS commons project, which hosts a bunch of JAX-WS related extensions, utilities, tools, etc. Anyone interested in hosting any code around the JAX-WS are welcome to join the project.

We'll be showing more about this (among other things!) in our JavaOne session TS-4948 "Unleashing the Power of JAX-WS RI: Spring, Stateful Web Services, SMTP, and More", so don't forget to plan your schedule accordingly...