Tuesday, September 16, 2014

How to kick start a WS project in few seconds

One of the goals I committed to when I joined the JBoss Web Services project back in 2007 was to improve the JBossWS tooling offer and possibly make the users' life easier when they have to deal with WS technologies.
Some of the solutions we developed in this area during the past years are now surpassed, others are still here and being used (as an example, think about the Wise project, which gets very limited attention from us due to lack of time, but currently powers the Web Service Tester within JBoss Tools, just to say).
In the last years Maven has been adopted as the de-facto standard solution for building projects; as a consequence, the JBossWS team made available a couple of Maven plugins for running its JAX-WS tools (wsconsume and wsprovide). As part of a customer project build it is hence possible to automatically generate a JAX-WS client or Service Endpoint Interface from a given WSDL contract and viceversa.
In February last year, with the aim of further clarifying how the plugins could be leveraged in final user projects, I wrote a post on the forum describing an example of the above mentioned Maven plugins.
The next step was to simplify the sample project creation and that's what has been eventually addressed. The JBossWS project now features a custom Maven Archetype, basically a WS-enabled project template toolkit.
Whenever a user needs to start a new project aiming at providing and/or consuming a JAX-WS endpoint, the new jaxws-codefirst archetype allows creating a starting project (including working build and sample helloworld client and endpoint) in few seconds. It's simply a matter of issuing a command and replying to simple questions on the desired artifact and group ids for the project being generated:

mvn archetype:generate -Dfilter=org.jboss.ws.plugins.archetypes:

The generated project includes:
  • a sample HelloWorld code-first POJO endpoint
  • an integration test that gets the WSDL contract for the above service, builds up a client and invokes the endpoint
  • a pom.xml for creating a war archive; the project has proper WS component dependencies and uses both wsprovide and wsconsume maven plugins for generating the contract for the code-first endpoint and then generating the client stubs for such contract
  • a plugin for deploying the archive on WildFly.
The project is built and tested by simply running:

mvn wildfly:deploy
mvn integration-test

The build processes the various plugins and calls into the JBossWS tools to generate all the required classes for building the deployment archive and client. The user can test the sample, have a look at the project structure and then either trash the sample endpoint and testcase and replace them with his own components, or modify them step-by-step to achieve what he needs. No need to start from scratch anymore :-)
A 1.0.0.Beta1 version of the archetype is currently available; it relies on JBossWS 4.2.3.Final and is out there for early testers. I've been fixing few bugs on it recently and the plan is to release a new version, based on JBossWS 5, together with the next release of the webservices stack. So give it a try and send us your feedback; we'll try to fix any issue before the release.

1 comment:

Rick said...

Thanks for using archetype to make this easy. (Not all of Maven is good, but I do like archetypes!)

Thanks also for working to help users get on board easier. Great ideas!

Best,

Rick