JavaWebServices

JAX WS HTTPS Hello World using Eclipse and Tomcat

In this article, we will create a soap service for HTTPS and deploy it on Tomcat.

We will first need to setup Tomcat for HTTPS. Please refer the below link for the setup:

Tomcat setup for HTTPS

Now lets create a webservice with User/Roles security.

Step 1:

Create a Dynamic Web Project using Eclipse and name it JAXWSWeb.

Step 2:

Create a package com.techkatak and create a @WebService Hello in it.

Step 3:

Add below web.xml file under WEB-INF.

Step 4:

Add sun-jaxws.xml file under WEB-INF.

Step 5:

Download metro jars and add them to the project.

The classes WSServletContextListener and WSServlet are present in jar file webservices-rt.jar

This jar along with other jars can be downloaded from Metro project(metro.java.net)and added in your project.

Copy the jar files webservices-rt.jar and webservices-api.jar into your project src folder and deploy your code on the Tomcat Server. (You can also use an Ant script for this as mentioned in Metro project website)

Here is how the project structure looks like:

projstr

Step 6:

Export the project as WAR file to webapps folder under Tomcat installation directory.

TOMCAT_HOME/webapps/JAXWSWeb.war

Step 7:

Stop and Start Tomcat using below scripts in bin folder under Tomcat installation directory.

shutdown.bat
startup.bat

Step 8:

Submit below URL now in browser now :

https://localhost:8443/JAXWSWeb

You should get a popup screen asking for credentials. Enter techkatak for both userid/pwd.. we added this in tomcat-users.xml file.

On successful validation, it will redirect you to the webservice page.

service

© 2015, www.techkatak.com. All rights reserved.