Create a Provider Web Service and Web Service Client (JAX-WS) + Apache Tomcat

Create a Provider Web Service and Web Service Client (JAX-WS) + Apache Tomcat

1). Open Eclipse, Create Dynamic Project ( WebServiceWSDL ), choose server tomcat, Next and Finish.


2). Set the package – – in the /src. Create java Class –


public class CalculateAdditional {
    public double addtheValues(double firstnumber, double secondnumber ) {
       double plus = firstnumber + secondnumber;
       return plus;


3). Right Click on file -> Web Services -> Create Web Service


  • First configuration : select start service
  • Second Configuration : select Test Client
  • Tick the Checkbox true (Publish the Web Service & Monitor the web Service)

Click Finish.

4). Then it will created the sub project folder for web service client testing “WebServicesWSDLClient“.


5). Run on Tomcat – for run web service client test .



Creating example jax-ws Service Provider + ejb 3.1 + mysql + webSphere v7.0 + RAD v 8.0.2- part 2

Creating example jax-ws Service Provider + ejb 3.1 + mysql + webSphere v7.0 – part 2

1.) Create EAR file, at your Rational Application Development – RAD, right click  select New > Enterprise Application Project > Project name : “studEAR” > Finish


2.) Create new Project EJB. New > Other > Java EE > Utility Project > Next > Project Name “studentEJB” >  Finish






Create Simple Web Service JAX-WS – Client Part – RAD IBM – Websphere 7.0 + java 6

Create Simple Web Service JAX-WS – Client Part – RAD IBM – Websphere 7.0 + java 6

1.) After you done doing my example on JAX-WS Server Part 1, you can create new Dynamic web project “jaxwsClientFirst” – for client part.

1.1.) Create package, com.fndong.client, then right click New > others > Web Service > Web Service Client


1.2.) Create package, com.fndong.client, then right click New > others > Web Service > Web Service Client.


Click on Browse Button of Service Definition and select the WSDL file of jaxwsServerFirst , Press Ok. Then set the target Location “com.fndong.client” > Next > Finish.

1.3.) Then it will generated java class automatically :


1.4.) Open class , inside the codes, change the URL to  :

url = com.fndong.client.SalaryImplService.class.getResource(“/WEB-INF/wsdl/SalaryImplService.wsdl”);


url = com.fndong.client.SalaryImplService.class.getResource(“http://localhost:9080/jaxwsServerFirst/SalaryImplService/SalaryImplService.wsdl”);

1.5.) This client jax-ws used WebSphere thin client jar for WebService Client. Right Click on jaxwsClientFirst  >BuildPath > Configure Build Path,Under Libraries Tab ->


Click on WebSphere Application Server v7.0. Click On Remove, and Press OK.

1.6.) Then add thin client jar , Right Click again on jaxwsClientFirst  >BuildPath > Configure Build Path,Under Libraries Tab ->  Add External JARs > add three jars below.


– click OK Button.

1.7.) Create a client program that invokes the server jaxwsServerFirst, by Creating new Client java class in the package com.fndong.client – ““.

 package com.fndong.client;

 * @author fndong
public class CalculateClient {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         SalaryImplService service = new  SalaryImplService();
         SalaryService salaryService = service.getSalaryImplPort();
         double var1 = 2000;
         double var2 = 5000;
         double mysalary = salaryService.calculateSalaryAllowance(var1, var2);
         System.out.println("my salary : " + mysalary);       



Create Simple Web Service JAX-WS – Server Part – RAD IBM – Websphere 7.0 + java 6

1). Create Simple Web Service JAX-WS – RAD IBM – Websphere 7.0 + java 6

1.1) Create your ear File first – Select New > Enterprise Application Project – “jaxwsServerEar” – Server Web Service  Part  1

1.2.) Create New Java Project – Select New > Dynamic Web Project– “jaxwsServerFirst


1.3) create your Interface class with package. Create Package – com.fndong.service  / create your Class web Service “SalaryService” ( The interface will list calculate the salary and allowance)

package com.fndong.service;

import javax.jws.WebMethod;
import javax.jws.WebService;

 * @author fndong
public interface SalaryService {
     public int calculateSalaryAllowance(double salary, double allowance);
  • The @WebService annotation marks the WebServiceFirst class as implementing a web service, which results in a deployable web service being produced.
  • The @WebMethod

1.4.) Create implementation class to calculate Salary and Allowance – “SalaryImpl

package com.fndong.Impl;

import com.fndong.service.SalaryService;

 * @author fndong
public class SalaryImpl implements SalaryService {
    public double calculateSalaryAllowance(double salary, double allowance) {
         return salary + allowance;


1.5.) Create Web Service for the Implementation Class “SalaryImp” by right SalaryImp > Web Services> create WebServices


  • Next > check the box – Generate WSDL file into the project.













Next > Next > Finish

1.6.) The Class “” will generated automatically and also WSDL files. ( Check inside WebContent Folder)


1.7.) The server started and test the result and also validate the WSDL.


1.7.1.) check the WSDL document in the browser.



1.8.) Test with WebServices Explorer, just right click wsdl->WebServices->Test with WebServices Explorer


1.9.) It will load the page in your RAD . You test the result of calculation between Salary and Allowance, for arg0 = 3000 and arg1 = 50 , Click Go Button, so the result at the Status – Body:


Selamat Mencuba (malay languange)

JAX-WS/Axis2/CXF – WebService Notes:

  1. SOAP WebServices

2. What are difference between technology web Service JAX-WS, Axis2 and CXF ?

  • 2.1). JAX-WS
  • JAX-WS stands for Java API for XML Web Services.
  • JAX-WS is a technology for building web services and clients that communicate using XML.
  • JAX-WS allows developers to write message-oriented as well as RPC-oriented web services.
  • Java API for XML Web Services (JAX-WS), is a set of APIs for creating web services in XML format (SOAP).
  • In JAX-WS, a web service operation invocation is represented by an XML-based protocol such as SOAP.
  • The  SOAP specification defines the envelope structure, encoding rules, and conventions for representing web service invocations and responses. 
  • These calls and responses are transmitted as SOAP messages (XML files) over HTTP.


2.2). Axis2

  • Apache Axis2™ is a Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack.
  • There are two implementations of the Apache Axis2 Web services engine – Apache Axis2/Java and Apache Axis2/C
  • Apache Axis 2 is also a framework that now supports JAX-WS (up to JAX-WS 2). It’s an improvement from Apache Axis. CXF supports up to JAX-WS 1.2.

2.3). CXF

  • CXF has better integration with Spring, and Camel(camel-cxf). 
  • CXF is its implementation by Apache.
  • Apache CXF is a framework that implements JAX-WS to generate Web Services Definitions and Java Proxy (from a Web Service Definitions).

3.) Types of  JAX-WS