Top
Interstage Studio User's Guide
FUJITSU Software

5.3.2 Creating the Web Service

The following approaches can be used to create a Web service as a Web application:

5.3.2.1 Exposing a Java Class as a Web Service

In order to expose a Java class as a Web service, the Java class must first be created. Naturally, an existing Java class can also be made into a Web service.
The Web service can then be created by declaring the @WebService annotation in the Java class and implementing the service you want to publish.

Creating the Java Class

To create the Java class, select [Class] from the [New] wizard. Creation of a special Java class is not required. Specify the source folder, package, and name to create the class.

Declaring the WebService Annotation

Code the @WebService annotation in the created Java class as shown below.

Example of using the WebService Annotation

package sample;

import javax.jws.WebService;

@WebService
public class Calc {
      public int add(int param1,int param2) {
            return param1 + param2;
      }
}

Implementing the Service

Define the method of the function you want to publish as a Web service, and implement the method.

5.3.2.2 Creating a Web Service from WSDL

In order to create a Web service from WSDL, the WSDL must first be created. Naturally, existing WSDL can also be used to create a Web service.
Then, the Web server can be created by creating a Web server that conforms to the WSDL and implementing the declared method.

Creating the WSDL

Select [Web Services] > [WSDL] from the [New] wizard and the WSDL can be created by the wizard. In addition, a special-purpose editor can be used to edit the WSDL.
For details on how to create and edit WSDL, refer to "5.3.4 Creating WSDL".

Creating a Web Service that conforms to the WSDL

In order to create a Web service that conforms to the WSDL, a Service Endpoint Interface must first be created from the WSDL. The Service Endpoint Interface can be created by selecting [Web Services] > [Web Service(JAX-WS)] from the [New] wizard.
For details on creating the interface using the wizard, refer to "5.3.5 Creating a Service Endpoint Interface from WSDL".

If the Service Endpoint Interface has been created, use the Java class wizard to create the class that implements the Service Endpoint Interface.
Select [Class] from the [New] wizard. To create the class that implements the Service Endpoint Interface, specify the following to generate it.

Code the @WebService annotation in the created Java class as shown below.

Example of using the WebService Annotation

package sample;

import javax.jws.WebService;

@WebService(endpointInterface="sample.Calc", wsdlLocation="CalcService.wsdl")
public class CalcImpl implements Calc {
      public int add(int param1,int param2) {
            return param1 + param2;
      }
}

Implementing the Method (Service)

Implement the declared method.