} }

 Files   Prepare   Run   Troubleshooting   Related Topics 

 

About the Example

This example shows how to use the wsdlc and jwsc Ant tasks in combination to create a WebLogic Web Service based on an existing WSDL file.

For the sake of clarity, the WSDL file (and resulting Web Service) is very simple. The Web service is called Temperature, and it contains a single operation getTemp that takes as input a String value and returns a hard-coded temperature float value.

The example shows how to first execute the wsdlc Ant task, which takes as input the WSDL file, and, based on the operations, parameters, return values, and so on in the WSDL, generates a set of artifacts that together provide a partial implementation of the Web Service described by the WSDL file. These components include:

After running the wsdlc Ant task and updating the wsdlc-generated JWS file, the example shows how to run the jwsc Ant task the JWS file to create a deployable Web Service. The only additional attribute specify in this case is the compiledWsdl attribute of the <jws> child element, which points to the wsdlc-generated JAR file that contains the JWS interface file and the data binding artifacts.

The example then deploys the Web Service to the examplesServer as usual, and generates a standalone Java client application that invokes the getTemp operation of the Temperature Web Service. The TemperatureClient.java application uses the JAX-RPC Stubs generated by the clientgen WebLogic Web Service Ant task, based on the WSDL of the Temperature Web Service.


 

Files Used in the Example

Directory Location:

MW_HOME/wlserver_10.3/samples/server/examples/src/examples/webservices/wsdl2service/

(where MW_HOME is the directory containing your WebLogic Server installation)

File

Click source files to view code.

Description

build.xml Ant build file that contains targets for building and running the example.
client/TemperatureClient.java Standalone client application that invokes the deployed TemperatureService Web Service. Uses the JAX-RPC Stubs generated by clientgen, based on the WSDL of the Web Service.
wsdl_files/TemperatureService.wsdl Existing WSDL file from which the wsdl2service Ant task generates the needed components, including the JWS interface that represents the TemperatureService Web Service that has a single method, getTemp.

 

Prepare the Example

 

Prerequisites

Before working with this example:

  1. Install WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Open a command window and set up your environment.

 

Configure WebLogic Server

  No special configuration is required for this example

 

Build and Deploy the Example

Change to the SAMPLES_HOME\server\examples\src\examples\webservices\wsdl2service directory, where SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\Oracle\Middleware\wlserver_10.3\samples.

  1. Execute the following command from the shell where you set your environment:

    prompt> ant generate.from.wsdl

    This command executes the wsdlc Ant task on the specified WSDL file to generate the components described in the introduction above.
  2. Using your favorite Java editor or IDE, open the file output\temperature\imp\net\xmethods\sd\temperatureServiceWsdl\TemperaturePortTypeImpl.java and modify the getTemp() method to return 101.0 rather than 0:
     public float getTemp(java.lang.String zipcode)
    {
    
       return 101.0f;
    }
    This simulates adding business logic to the JWS implementation file.
  3. Execute the following command from the shell where you set your environment:

    prompt> ant build.service client

    The build.service target executes the jwsc Ant task which compiles and builds the Web Service; the client target builds the client application that invokes the Web Service.
  4. Execute the following command from the shell where you set your environment:

    prompt> ant deploy

    This command deploys the example on the wl_server domain of your WebLogic Server installation.

 

Run the Example

To run the example, follow these steps:

  1. In your development shell, run the client/TemperatureClient Java application by using the following command from the main example directory (SAMPLES_HOME\server\examples\src\examples\webservices\wsdl2service):

    prompt> ant run

  2. After building and running the example, you can view the WSDL of the Temperature Web Service in your Web browser:

    http://host:port/soap/servlet/rpcrouter?WSDL

    where

    This URL is the same as the value of the location attribute of the <soap:address> element in the original WSDL, except that the host and port of the hosting server is obviously changed to that of WebLogic Server.

 

Check the Output

If your example runs successfully, you will get the following message in the command shell from which you ran the client application:

Buildfile: build.xml

run:
[java] Got resut: 101.0

BUILD SUCCESSFUL
Total time: 6 seconds


 

Troubleshooting


 

Related Topics

(Internet connection required.)