February 28, 2010

Using JAX-WS in a Web Archive, as a Servlet, Running on JBoss 5.1

In my previous blog I showed how to get started with JAX-WS in a EJB archieve, in this blog I will show you how to do the same thing, but in a web archive instead, as a Servlet. If you think about it, the two different approaches ends with the same result – a Servlet that answer HTTP request with SOAP content.

Now lets create a simple web archieve with Maven archetype plugin.

Now lets add EJB dependency and JBoss Maven plugin that will do our deployment work.

Then we continue with our Web Service class.

Not that we don't need to define a interface. Then we write our web.xml, that points to our concrete Web Service class.

Finally we need to add the JBoss specific web deployment descriptor. Note the location of the file – src/main/webapp/META-INF/jboss-web.xml, i.e. not in the WEB-INF directory, beside the web.xml.

Now we are ready to build and deploy our archieve

Then we start our JBoss server and opens a web browser pointing to http://localhost:8080/ws-web/personServiceBean?wsdl and checks that the web service is working. Instead of building a web service client by hand, we use the soapUI tool.



Now soapUI has created us a testcase that we can double click and click the green play button on.

No comments: