Package examples.webservices.handler.nocomponent

This example shows how to create a WebLogic Web service that consists of just a handler chain with no backend component.

See:

 

Class Summary

Client This class illustrates how to use the JAX-RPC API to dynamically invoke a WebLogic Web service implemented with just a handler chain.
EchoStringHandler Class that implements the weblogic.webservice.GenericHandler abstract class.
 

Package examples.webservices.handler.nocomponent Description

This example shows how to create a WebLogic Web service that consists of just a handler chain with no backend component.

The handler chain contains a single handler called EchoStringHandler. This handler implements the javax.xml.rpc.handler.Handler interface. The implementation of the handleRequest method does nothing. The implementatin of the handleResponse method, however, builds a SOAP response message that includes the ever-present "Hello World" text, and sends this new SOAP response back to the client.

The handler chain makes up the Web service operation called echoString. When a client application invokes this operation, the EchoStringHandler handler does nothing with the SOAP request message, but creates a custom SOAP response message and sends it back to the client application. Note that no backend component is ever called.

This example does not use servicegen to generate the web-services.xml file, but rather shows an already created deployment descriptor that defines the EchoStringHandler handler that's part of the EchoHandlerChain handler chain and the echoString public operation implemented by the handler chain.

The build.xml file compiles, assembles, packages, deploys, and runs the example.

Client.java is a dynamic client application that does not use the WebLogic-generated client JAR file to invoke the Web service. Rather, the client application dynamically discovers the public operations, using the javax.xml.rpc.Call JAX-RPC API, based on the URL of the Web service.

  Additional Resources for examples.webservices.handler.nocomponent

web-services.xml The Web services deployment descriptor file that describes the EchoHandlerChain handler chain, the single handler, EchoStringHandler, and the echoString operation implemented by the handler chain.
application.xml The application deployment descriptor.
build.xml The Java Ant build script that compiles the handler class, creates a WAR file that contains the web-services.xml file, then packages all these components into a deployable EAR file. The build file also compiles the dynamic client application.

 

The following sections describe how to build and run the example.

  1. Prerequisites
  2. Build the Example
  3. Run the Example
  4. Check the Output

 

Prerequisites

Before you run this example, you need:

  • WebLogic Server Version 8.1

 

Build the Example

To build the example, follow these steps:
  1. Set up your development shell as described in Quick Start.

  2. Change to the $SAMPLES_HOME\server\examples\src\examples\webservices\handler\nocomponent directory, where SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\beahome\weblogic81\samples.

  3. Assemble and compile the example by executing the Java ant utility at the command line:
    prompt> ant

 

Run the Example

  1. Start the examples WebLogic Server.

  2. In your development shell, run the Client Java application using the following command:
    prompt> ant run 
  3. After building and running the example, you can view the Web Service Home Page using the following URL:

    http://www.setgetweb.com:port/handler_nocomponent/EchoString

    where

    • www.setgetweb.com refers to the machine on which WebLogic Server is running
    • port refers to port on which WebLogic Server is listening

    From the Web Service Home Page you can view the generated WSDL, and test the Web service to make sure it's working correctly.

 

Check the Output

If the example executes successfully, you should see the following output from the client:
[java] Calling Web Service at: http://www.setgetweb.com:7001/handler_nocomponent/EchoString?WSDL
     [java]
     [java] The client passed the value "BEAS" to the webservice. Since this is a non-existent method, we expect to get back only the results of the 
handleResponse method:
     [java] Hello World
You should see the following output in the command window from which you started WebLogic Server:
** handleRequest called in: 10055979

 

See Also

Read more about: