Files Prepare Run Troubleshooting Related Topics
This example shows how to create a simple WebLogic Web Service using JWS metadata annotations.
Metadata annotations are a new J2SE 5.0 feature that provides the ability to associate additional data alongside Java classes, interfaces, methods, and fields. The set of annotations used to annotate Web Service files are called JWS annotations. WebLogic Web Services use standard JWS annotations, as defined by the Web Services Metadata for the Java Platform specification (JSR-181) as well as WebLogic-specific ones for added value.
The generated Web Service in this example, called Simple, has a single operation, sayHello(String), that returns the input String parameter.
The SimpleImpl.java Java source file (also called JWS file) forms the basis of the Web Service. The file uses both standard (defined by JSR-181) and WebLogic-specific JWS annotations to define the shape and behavior of the Web Service.
In particular, the JWS file uses the following standard JWS annotations:
The JWS file uses the following WebLogic-specific JWS annotation:
To use the various JWS annotations, you must first import the annotation interfaces into your JWS file:
//Standard JWS annotations
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
//WebLogic-specific JWS annotation
import weblogic.jws.WLHttpTransport;
The SimpleImpl.java file defines a single public method that is exposed as a Web Service operation: sayHello(String). Because the @WebMethod annotation on the method does not specify the operationName attribute, the public name of the operation in the WSDL will be the same as the name of the method: sayHello.
To generate a Web Service from the JWS file, use the jwsc WebLogic Web Service Ant task, as shown in the build.xml file. This Ant task compiles the JWS file, and generates the additional files needed to implement a standard Java EE Web Service: the Web Service deployment descriptors, the WSDL file, and so on. The Ant task automatically generates all the components into an Enterprise Application directory structure, which you can then deploy to WebLogic Server. This example uses the wldeploy WebLogic Ant task to deploy the Web Service.
The Client.java class is a standalone Java application that invokes the sayHello operation of the Simple Web Service. It uses the JAX-RPC Stubs generated by the clientgen WebLogic Web Service Ant task, based on the WSDL of the Simple Web Service.
Directory Location:
BEA_HOME/wlserver_10.3/samples/server/examples/src/examples/webservices/jws_basic/simple/
(where BEA_HOME is the directory containing your WebLogic Server installation)
File Click source files to view code. |
Description |
|---|---|
| SimpleImpl.java | Java source file that contains the JWS metadata annotations (both standard and WebLogic-specific) that define the JWS-implemented Web Service. |
| Client.java | Standalone client application that invokes the deployed Web Service. Uses the JAX-RPC Stubs generated by clientgen, based on the WSDL of the Web Service. |
| JWS_WebService.jsp | JSP file that is invoked when you click on the Run the example link for this example from the main Examples Server JSP. |
| build.xml | Ant build file that contains targets for building and running the example. |
Before working with this example:
There are no server configurations for this example.
wl_server domain
of your WebLogic Server installation. To run the example, follow these steps:
prompt> ant run
http://host:port/jws_basic_simple/SimpleService?WSDL
where
If your example runs successfully, you will get the following message in the command shell from which you ran the client application:
Buildfile: build.xmlrun: [java] Got result: Here is the message: 'Hi there!'BUILD SUCCESSFUL Total time: 7 seconds
(Internet connection required.)
Copyright © 1996, 2008, Oracle and/or its affiliates. All Rights Reserved.