Hessian:
Hessian是一个轻量级的remoting onhttp工具,使用简单的方法提供了RMI的功能。 相比WebService,Hessian更简单、快捷。采用的是二进制RPC协议,因为采用的是二进制协议,所以它很适合于发送二进制数据。
参考: http://www.cnblogs.com/yjmyzz/p/hessian-helloworld.html
需要注意的情况:
web.xml 中的配置和映射;
导出jar包,让客户端引用;
测试的时候将tomcat启动;
package cn.com.p2p.test;
import java.net.MalformedURLException;
import org.junit.Test;
import cn.com.p2p.hessian.HelloService;
import com.caucho.hessian.client.HessianProxyFactory;
public class ServiceTest {
@Test
public void testService() throws MalformedURLException {
String url = "http://localhost:8888/TestWeb/hessian";
System.out.println(url);
HessianProxyFactory factory = new HessianProxyFactory();
HelloService helloService = (HelloService) factory.create(HelloService.class, url);
System.out.println(helloService.helloWorld("高勇"));
}
}

浙公网安备 33010602011771号