Tuesday, August 14, 2007

Bottom Up JAX-RPC web service with JWSDP

A simple step by step guide to develop a bottom up web service using Java Web Services Developer Pack.

Step #1 Install JWSDP

Download Java Web Services Developer Pack 1.6 (JWSDP) from http://java.sun.com/webservices/downloads/webservicespack.html and install it. The installation directory will be called hereafter as $JWSDP_HOME.

Step #2 Write code and Package war file

Write an interface and implementation of it. This interface will be exposed as web service through servlet end-point. Write a configuration file named jaxrpc-ri.xml and save it in WEB-INF folder of the project. This configuration file contains information about web service interface and it’s implementation, location of WSDL file, web service URL. All these information will be used by JWSDP at the time of processing input war file for generating web service.

The jaxrpc-ri.xml looks like below-

<?xml version="1.0" encoding="UTF-8"?>

    displayName="My Web Service"
    description="Test JAX-RPC web service"
    implementation="myPackage.MyWsImplementation" />

    urlPatternBase="/myWs" />

The web.xml must have following entries-


Step #3 Process war file

Copy above created war file say myWS-in.war to $JWSDP_HOME/jaxrpc/bin directory and create a directory named tmp there. Open command prompt and go to above mentioned directory and fire following command-

$ wsdeploy -o myWs.war myWs-in.war -keep -tmpdir ./tmp -verbose

This will create a war file
myWs.war, which is ready to be deployed on Tomcat.

Step #4 Deploy Processed war file on Tomcat

Now deploy the processed war file,
myWs.war on Tomcat and start Tomcat.

Step #5 Generate Web Service client

Create a file named config.xml with following contents-
<configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
  <wsdl location="http://localhost:8080/myWs/myWs?WSDL"
  packagename="myWsClient" />
Here location is the URL of the web service WSDL, which may change according to server installation, hence update it accordingly and packageName is the package name of the generated web service client classes, which could also be changed to anything.
Save config.xml in $JWSDP_HOME/jaxrpc/bin directory. Now fire following command-
$ wscompile -gen:client -keep config.xml

This will create a directory name
$JWSDP_HOME/jaxrpc/bin/myWsClient, create a jar file containing this directory. This way web service client is ready. This directory name depends upon the packageName specified in config.xml.

An example of client accessing web service is given below-
public class WsTest {

  public static void main(String[] args) {
    try {
      MyWsImpl stub = new MyWsImplService_Impl().getXXX();
      ((Stub)stub)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://myHost/myWs/myWs");
      // call the desired method
      stub.xxxXXX(. . .);
    } catch (Exception e) {



Anonymous said...

How do i configure JAX-WS on eclipse.What IDE used for creating a sample web service.

Anonymous said...

There is nothing to configure about JAX-WS. See this post http://blog.vinodsingh.com/2008/09/building-jax-ws-web-service.html for details about building JAX-WS web services.

Biswajit said...

HI VINOD, I REALLY LIKE YOUR blogging style.
Could you please let me know how do you add source code in your blog. It looks like some editor. I am refereing to your blog "Bottom Up JAX-RPC web service with JWSDP " where you have embedded some source code in some special format.

Anonymous said...


Code formatting is done using
Syntax Highlighter.

Anonymous said...

Vinod,Thanks for your article. I tried your JAX_WS on Jboss 4.2.3GA. It is working fine.

I need your help to add FAULT to the existing webservice.

Need your advice / samples.


Anonymous said...

Hi Vinod

I use stament
D:\JAVAProjects\WSDPExample01>%JWSDP_HOME%\jaxrpc\bin\wsdeploy.bat -verbose -o temp/myWStest.war temp/TestWEB_INF.war

to create WS war file, but I can't do that.
No error message appear.
Pls help me to solve this problem


tieuduong said...

Thanks for your document. I have just resolved my issue by it.
Nguyen Van Hoan

Unknown said...

Best eCOGRA Sportsbook Review & Welcome Bonus 2021 - CA
Looking for 1xbet app an eCOGRA sol.edu.kg Sportsbook https://deccasino.com/review/merit-casino/ Bonus? At this eCOGRA Sportsbook review, casinosites.one we're talking about a variety of ECCOGRA sportsbook poormansguidetocasinogambling promotions.