Versions Compared

Key

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

JAXB 2.0 now supports StAX natively and integrates easily into ActiveSOAP.

Here is an example application which demonstrates writing a simple POJO based services using purely JAXB and letting ActiveSOAP be the REST or SOAP stack and handling the HTTP or JMS transports for you.

First you need some kinda service to expose. So we wrote a little interface.

Wiki Markup
{snippet:id=example|lang=java|url=http://cvs.activesoap.codehaus.org/viewrep/~raw,r=HEAD/activesoap/activesoap/modules/jaxb/src/test/org/codehaus/activesoap/examples/jaxb/SnowboardService.java}

There's a method on this interface which accepts a regular Java POJO marshalled via JAXB. We can have as many methods as we like all auto-published, the only requirement is that the parameter must be a type marshalled by JAXB, so that when we register it with JAXBRegistry it can handle the XML marshalling.

Then if we register an implementation of this interface with the JAXBRegistry we can automatically publish the service as both REST and SOAP endpoints...

Here's the SOAP server side

Wiki Markup
{snippet:id=soapServer|lang=java|url=http://cvs.activesoap.codehaus.org/viewrep/~raw,r=HEAD/activesoap/activesoap/modules/jaxb/src/test/org/codehaus/activesoap/examples/jaxb/SnowboardTest.java}

And here's the SOAP client side

Wiki Markup
{snippet:id=soapClient|lang=java|url=http://cvs.activesoap.codehaus.org/viewrep/~raw,r=HEAD/activesoap/activesoap/modules/jaxb/src/test/org/codehaus/activesoap/examples/jaxb/SnowboardTest.java}

Or the REST client side...

Wiki Markup
{snippet:id=restClient|lang=java|url=http://cvs.activesoap.codehaus.org/viewrep/~raw,r=HEAD/activesoap/activesoap/modules/jaxb/src/test/org/codehaus/activesoap/examples/jaxb/SnowboardTest.java}