Developing Clients for a JAX-WS Web Service has been edited by Sainath Chowdary (Jul 04, 2008).

(View changes)

Content:

This tutorial will take you through the steps required in developing, deploying and testing a Web Service Client in Apache Geronimo for a web services which are already deployed on the server

This tutorial will take you through the steps involved in creating a Web based Client and a POJO Client for a JAX-WS web service. Here we will only be needing the WSDL file of the web service deployed for creating the client.

Types of Web Services

For new users, Web Services can be created in two ways:

  • Bottom Up Web Service - creating web services from Java classes.
  • Top Down Web Service - creating web services from WSDL document.

This tutorial will help you in creating a Top Down Web Service from WSDL document which is already deployed on server.

To run this tutorial, as a minimum you will be required to have installed the following prerequisite software.

  • Sun JDK 5.0+ (J2SE 1.5)
  • Apache Geronimo 2.x
  • Eclipse IDE for Java EE Developers - Europa release
  • Geronimo Eclipse Plug-in 2.x

Details on installing eclipse are provided in the Development environment section.

This tutorial assumes that you have completed the Developing a JAX-WS POJO Web Service tutorial. Here we will try to develop the client for the web service deployed in the above mentioned tutorial.

This tutorial will take you through the following steps:

Web based Client

Create a Dynamic Web Project to consume the Web Service

  • From Eclipse main menu, select File->New->Other

  • In the New dialog, select Web->Dynamic Web Project and click Next

  • Type jaxws-converterclient as the Project Name and click Next

  • On the Project Facets page, the default selections are enough.

  • Make sure that the check box Generate Deployment Descriptor is selected and click Next

  • On the Geronimo Deployment Page modify the Group Id to org.apache.geronimo.samples.jaxws and the Artifact Id to jaxws-converterclient.

  • Click Finish

Creating necessary stubs to consume Web Service

We need to create Service Endpoint Interface based on the WSDL document to use it in out JSP's. Luckily in Geronimo this can be automated using the jaxws-tools utility provided by Geronimo.

Please take care that jaxws-tools.bat utility in server's bin directory may not work in old versions of Apache Geronimo.
Try using the latest version of Geronimo i.e v2.1.1 .

  • Open a command prompt and point it to the bin directory of server installation.

  • We will use the jaxws-tools utility provided in the server's bin directory to generate client stubs.

  • Use the following command to generate the necessary stubs that are needed to consume the web service.
Client Stubs Generation
<%SERVEER_INSTALLATION_BIN_DIR%>:\ jaxws-tools.bat wsimport -s C:\WSDL http://localhost:8080/jaxws-conveter/converter?wsdl
  • Now all the stubs should have been created and placed in C:\WSDL directory. We will be needing only the class ConverterPortType for accessing Web Service.

  • Copy the file ConverterPortType according to its package declaration into the project.

Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences