Newsletter:

(Documentation) Developing a Web Service from existing Java Class

Documentation : Developing a Web Service from existing Java Class

Introduction
The Oracle Application Server provides the facilities for making a standard java object accessible via a web service interface. This how-to will detail the steps required for exposing an existing class as a web service available to remote clients.

The process of exposing an existing java object as a web service and creating an associated client application involves:

  • Creating a service interface. This interface exposes the functionality and operations the service provides.
  • Creating a service implementation class. This class simply provides implementations for each of the methods declared in the service interface. In this example the implementation class will instantiate, and delegate method calls to, the underlying bank object.
  • Generating the web service's WSDL file and associated artifacts (mapping file, etc.). A WSDL file is generated based on the service interface provided so that clients can now be created to access the web service.
  • Packaging the service as an application module. The service classes and all associated generated artifacts are packaged up as standard J2EE deployment modules.
  • Deploying the service. The service module is deployed to the Oracle Application Server.
  • Generating the client proxies. Client proxies/stubs are generated from the WSDL file for the deployed service.
  • Writing a client application. An application is written that leverages the client proxies to invoke remote service operations.

Admittedly, the argument could be made that it may be simpler to simply modify the existing java class and expose it directly as a web service (removing the requirement for creating the service implementation class as noted above). Although that is a possibility the more general, and potentially more frequent, case is that the existing class can not be modified. Rather, the functionality provided by the existing class needs to be exposed to remote clients without alteration to the target class. It is this scenario we will explore in the following sample.

What are the Prerequisites?

What Should You Know?

  • Some familiarity with the standard J2EE deployment model.

What are the Software Requirements?

  • OracleAS 10.1.3 is installed, available from OTN
  • Sun's JDK 1.4.2_03 or above, available here
  • Apache Ant 1.6.2 or above, to build the application,

[Read More..]

Courtesy:- Oracle.com