Top
Interstage Studio User's Guide
FUJITSU Software

5.1.1 What is a Web Service?

A Web service is technology that enables public access to system functions as a service via a network. Web services are being acclaimed as a method that promotes efficient utilization of existing systems and reuse of software.
Use of SOAP, using HTTP for low-level protocol, for communications and use of WSDL to define the interfaces of published services have become the standards for implementing such Web services.
In addition, interoperability is an important aspect of Web services, and ambiguous constraints and Web service specifications (SOAP/WSDL/UDDI and so on) are clarified by being prescribed by WS-I Basic Profile.

In practice, Web service provision is implemented by providing a Service Endpoint, and the Service Endpoint Interface is determined on the basis of the following conventions:

Point

The development method can be either top-down development, in which the Service Endpoint Interface is designed using WSDL, or bottom-up development, in which the Java class that will be the Service Endpoint is created and the Service Endpoint Interface is determined as a result of that.

5.1.1.1 Modifications since J2EE1.4

The following specification differences exist between J2EE1.4 Web services and Java EE Web services:

Simple examples of the main annotations used during Web service development are shown below while introducing Web services under Java EE.

javax.jws.WebService Annotation

This annotation defines a class as a Web service. The following properties can be specified.

Property Name

Explanation

endpointInterface

Define the Service Endpoint Interface if you do not want to make all the class methods public, and use this property to declare it.

name

Name of the WSDL portType

portName

Name of the WSDL port

serviceName

Name of the WSDL service

targetNamespace

WSDL namespace

wsdlLocation

Use this property if a Web service is published based on an already defined WSDL.

Example of using the WebService Annotation to create a Web Service

package sample;

import javax.jws.WebService;

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

javax.xml.ws.WebServiceRef Annotation

This annotation sets a Dependency Injection when invoking a Web service. The following properties can be specified.

Property Name

Explanation

mappedName

Mapped resource name

name

JNDI name

type

Java type of the resource

value

Service class

Normally, javax.xml.ws.Service is inherited.

wsdlLocation

Specify the WSDL location.

Example of using the WebServiceRef Annotation to create a Web Service Client

@WebServiceRef(name="service/Calc")
private CalcService service;

public int callCalc(int param1,int param2) {
      Calc port = service.getCalcPort();
      	return port.add(param1,param2);
}