JAX-WS: Hello World With Tomcat – RPC Style

Connect with

Oracle JavaJAX-WS is java API for producing and consuming SOAP styled webservice. JAX-Ws is a successor of JAX-RPC (java API for Remote Procedure Call).

In this post we go through basic of JAX-WS, we are not coverting any build tool i.e. maven , gradle , ant or any another for creating jax-ws artifacts. we use wsgen command line utility tool to create jaxb artifact for input request and output response class.

1. Environment & Technologies

I have tested this demo project following environment:

  • Eclipse IDE
  • JDK 7
  • Tomcat 7
  • wsgen

2. Steps to Create and deploye Hello World JAX-WS

step #1. create DynamicWeb project in Eclipse

Step #2. copy jar files (jaxb-api.jar, jaxb-impl.jar, jaxws-rt, stax-ex.jar, streambuffer.jar) into application lib (i.e. /WEB-INF/lib/) folder.

Step #3. Write java webservices class i.e. SEI (Service Endpoint Interface) and SEB (Service endpoint Bean)

Step #4. write sun-jaxws.xml (SUN java webservices deployment descriptor) under you project i.e. /WEB-INF/sun-jaxws.xml

Step #5. generate JAXB artifact or classess for input and output typs using wsgen by using command line utility or any another way.

Step #6. copy generated files into a package i.e. jaxb or jaxws (com.mysoftkey.helloworld.jaxws) of your application

Step #7. deploy the application in you webserver (Tomcat )

3. Directory Structure of Web project

│   .classpath
│   .project
│   readMe.txt
│   └───com
│       └───mysoftkey
│           └───jaxws
│               └───hellowold
│                   │   HelloWorld.java
│                   │   HelloWorldImpl.java
│                   │
│                   └───jaxws
│                           SayHelloWorld.java
│                           SayHelloWorldResponse.java
        │   sun-jaxws.xml
        │   web.xml
        │   └───com
        │       └───mysoftkey
        │           └───jaxws
        │               └───hellowold
        │                   │   HelloWorld.class
        │                   │   HelloWorldImpl.class
        │                   │
        │                   └───jaxws
        │                           SayHelloWorld.class
        │                           SayHelloWorldResponse.class

4. SEI (Service Endpoint Interface)

File: HelloWorld.java

package com.mysoftkey.jaxws.hellowold;
import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService // SEI (Service Endpoint interface) SIB (Service Implementation Bean)
public interface HelloWorld {

	public String sayHelloWorld(String name);

5. SIB (Service Implementation Bean) class

File: HelloWorldImpl .java

package com.mysoftkey.jaxws.hellowold;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@WebService(endpointInterface = "com.mysoftkey.jaxws.hellowold.HelloWorld")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class HelloWorldImpl implements HelloWorld {

 public String sayHelloWorld(String name) {
  return "Hello world JAX-WS, " + name;


6. Web Deployment Descriptor web.xml



7. Sun Java webservice deployement descriptor (sun-jaxws.xml)

sun-jaxws.xml is a proprietary deployment descriptor which is needed when java web services are deployed as a standard WAR (as .war fashioned) on a non-Java EE5 servlet container using the SUN’s reference implementation.

Sun’s RI (Reference implementation) uses WSServletContextListener as the listener for servlet context events and WSServlet as the dispatcher servlet( like spring Front controller or any frontController); both of which have to be mentioned in web.xml (web deployment descriptor). The sun-jaxws.xml file is then required to define web service end points for the WSServlet to let it know to which end point a service request must be dispatched.

In this way, web services can be run in any JAX-WS RI enabled servlet container, although they won’t be portable.
File: sun-jaxws.xml



Note: in the above wsdlLocation is optional attribute under endpoint element of sun-jaxws.xml.

8. Create JAXB artifact using wsgen tool

step #1. open cmd/terminal ( window/linux)
follow any one of the following steps
– Go up to src (e:\workspace\HelloWorldWS\src\) till com folder and run following
– wsgen
step #2.


9. Deploy web application in Tomcat

there are different approach of depoying of web application. You can choose any one of your comfortable way to deploy.
– build a .war file and copy in ${tomcat}/webapp/ folder and restart the tomcat
– configure local server of Tomcat under Eclise to run web project

10. Access JAX-WS web Application

Now you are ready to access java exposed application There are different way of running Java Webservice application,

URL: http://localhost:8080/HelloWorldWS/HelloWorldWS
Web Services
[table “” not found /]

11. WSDL (Web Service Deployement Descriptor Language)








XSD (XML Schema Definition)

Generated XSD can be accessed via following URL.

XSD URL: http://localhost:8080/HelloWorldWS/HelloWorldWS?xsd=1




Run Java Web web service

there are different way of accesing web service as:
– by using SOAPUI
– Generate java client by using wsdl (http://localhost:8080/HelloWorldWS/HelloWorldWS?wsdl )


You can download this source code from github. open git terminal and run following code

git clone https://github.com/ranrose/HelloWorldWS.git

or you can download source code of Hello Wold WS web project from mysoftkey portal.

Your comments are welcome to improve this post. Happy Learning 🙂

Connect with

4 thoughts on “JAX-WS: Hello World With Tomcat – RPC Style

Leave a Reply

Your email address will not be published. Required fields are marked *