hessian (Java 篇)

一服务器开发步骤

1. Download   hessian-x.x.x.jar 

2. 创建javaWeb项目 hessian-server-demo

3. 将 hessian-x.x.x.jar 导入项目 或者 拷贝到


hessian-server-demo 项目结构图



开发步骤

1. 开发功能接口  该功能接口 是个服务器 和 客户端的统一调用接口

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Hessian是一种轻量级的二进制RPC协议,它可以使得Java和其他语言之间的通信变得更加简单和高效。下面是一个简单的Hessian服务端和客户端的例子: 服务端(Java): 1. 首先,需要在pom.xml文件中添加以下依赖: ```xml <dependency> <groupId>com.caucho</groupId> <artifactId>hessian</artifactId> <version>4.0.38</version> </dependency> ``` 2. 创建一个实现了Hessian服务接口的类,例如: ```java public class HelloServiceImpl implements HelloService { public String sayHello(String name) { return "Hello, " + name + "!"; } } ``` 3. 在Spring配置文件中添加以下内容: ```xml <bean id="helloService" class="com.example.HelloServiceImpl"/> <bean id="hessianServiceExporter" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="helloService"/> <property name="serviceInterface" value="com.example.HelloService"/> </bean> ``` 4. 启动应用程序,服务端就可以监听来自客户端的请求了。 客户端(C#): 1. 首先,需要在项目中添加对HessianSharp.dll的引用。 2. 创建一个HessianProxyFactory对象,并使用它来创建一个HelloService接口的代理对象,例如: ```csharp HessianProxyFactory factory = new HessianProxyFactory(); HelloService service = (HelloService)factory.Create(typeof(HelloService), "http://localhost:8080/helloService"); ``` 3. 调用代理对象的方法,例如: ```csharp string result = service.sayHello("world"); Console.WriteLine(result); ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值