In today’s post, I’m going to walk through a simple SOAPweb service creation using maven, jax-ws for java. The service will be hosted inside of Apache Tomcat once we’re up and running.
Maven
First off, we start the application off with maven.
This creates our project structure and puts all of the project dependencies in place. The pom.xml that gets generated for us needs a little extra help for a JAX-WS project. We need to:
Set the packaging to war
Add the jaxws-rt dependencies
Supply a final name
Your pom.xml should look something like this:
The two references that I had to make were the following were one of jaxws-rt
and one for istack-commons-runtime.
Service implementation
We now write our service implementation. For this purposes of this article will be very simple. I took over the pre-generated App.java and renamed it for my purposes to HelloService.java.
Fairly basic, “hello” type service.
Endpoints
We instruct the jaxws framework that we have a service listening at any particular given endpoint by use of the sun-jaxws.xml file. Create this file in src/main/webapp/WEB-INF. It should look like this:
To let Tomcat know from a deployment perspective what this application will handle, we also create a web.xml file that will be located in the same directory, src/main/webapp/WEB-INF. It looks like this:
Now that the service is up and running, we really want to test it to make sure it’s working. SOAP requests are HTTP POSTS. Sending the following request: