Creating a Web Service with JAX-RPC

本文介绍了创建远程服务的三个主要步骤:编码服务端点接口及其实现类;构建、生成及打包服务所需文件;部署包含服务的WAR文件。此外还详细说明了服务端点接口必须遵循的规则。

 

These are the basic steps for creating the service:

1. Code the service endpoint interface and implementation class.

A service endpoint interface must conform to a few rules: • It extends the java.rmi.Remote interface. • It must not have constant declarations, such as public final static. • The methods must throw the java.rmi.RemoteException or one of its subclasses. (The methods may also throw service-specific exceptions.) • Method parameters and return types must be supported JAX-RPC types. See the section Types Supported By JAX-RPC (page 456). In this example, the service endpoint interface is HelloIF.java: package helloservice; import java.rmi.Remote; import java.rmi.RemoteException; public interface HelloIF extends Remote { public String sayHello(String s) throws RemoteException; }

 

In addition to the interface, you’ll need the class that implements the interface. In this example, the implementation class is called HelloImpl: package helloservice; public class HelloImpl implements HelloIF { public String message =“Hello“; public String sayHello(String s) { return message + s; } }

2. Build, generate, and package the files required by the service.

The process includes below steps:

• compile-service

• generate-sei-service

• package-service

• process-war

3. Deploy the WAR filethat contains the service.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值