Tuesday, August 19, 2014

JAX-WS Servlet Endpoint

The basic steps to write a Servlet end point approach is:
  • Write a POJO class
  • Annotate it
  • Configure in web.xml
  • Build and deploy.

WSDL file is generated automatically
Make a web application. In eclipse you can make a project which is a dynamic web project.

Let's write a POJO bean class which can be invoked by sending a SOAP Request which contains a string and it will return the response "Hello World" + input String.

POJO class:

public class HelloBean{

public String hello(String name){
   return "Hello " + name;

Note the annotation on the bean class. The class does not implements any interface.
Register this bean as a servlet in the web,xml



Deploy the war in your server and hit the service at:


Please change the host name with your host name and JAX_WS_HelloWorld with your application context.
You can also follow the video:


  1. I get - java.lang.ClassCastException: biz.dss.HelloBean cannot be cast to javax.servlet.Servlet
    on GlassFish server

    1. This example was tried on JBoss server. However looking to the exception you are getting, it looks like configuration issue.