Java - Java Web Service (JWS) (Annotation Method)


Instead of coding the raw Java class or EJB directly, you use the JWS annotations programming model, which makes programming a WebLogic Web service much easier.

This programing model takes advantage of the new JDK 5.0 metadata annotations feature in which you create an annotated Java file and then use Ant tasks to compile the file into a Java class and generate all the associated artifacts.

The Java Web Service (JWS) annotated file is the core of your Web service. It contains the Java code that determines how your Web service behaves.

A JWS file is an ordinary Java class file that uses annotations to specify the shape and characteristics of the Web service.

The JWS annotations you can use in a JWS file include:

  • the standard ones defined by the JSR 181:Web Services Metadata
  • as well as a set of other standard or WebLogic-specific annotations, depending on the type of Web service you are creating.

The Java Web Service (JWS) file that implements the Web service uses just the one required JWS annotation: @WebService.

A JWS file is a standard Java file that uses JWS metadata annotations to specify the shape of the Web service. Metadata annotations were introduced with JDK 5.0, and the set of annotations used to annotate Web service files are called JWS annotations.



The Java Web Service (JWS) file that implements the Web service uses the JWS annotation: @WebService to specify that the JWS File implements a Web Service.

The standard @WebService annotation:

  • specify, at the class level, that the JWS file implements a Web service.
  • Marks a Java class as implementing a Web Service, or a Java interface as defining a Web Service interface.


@WebService(name="SimplePortType", serviceName="SimpleService",targetNamespace="")


  • SimplePortType is the name of the Web service. It will later map to the wsdl:portType element in the WSDL file generated by the jwsc Ant task.
  • SimpleService is the service name. It will map to the wsdl:service element in the generated WSDL file.
  • is the target namespace used in the generated WSDL.


  • @WebMethod to specify explicitly that a method should be exposed as a Web service operation and to change its operation name from the default method name,
  • @WebParam and @WebResult to configure the parameters and return values,
  • and @SOAPBinding to specify the type of Web service.

Documentation / Reference

Powered by ComboStrap