Spring 整合 Hessian

Spring Hessian整合 404 问题 今天正在看Spring in Action,看到Spring与Hessian整合,按照书上的例子写的代码,客户端却无论如何都报错404,最后终于发现问题 先贴代码 POJO类,我用的是自己随便编的一个Item类,没有用书上的Spitter类,这里一定要注意要实现Serializable接口,否则会报错 package spittr.domain; import java.io.Seri 阅读详情

一:服务端

web.xml
	<!-- DispatcherServlet -->
	<servlet>
		<servlet-name>Spring-DispatcherServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/config/applicationContext-hessianServer.xml</param-value>
		</init-param>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>Spring-DispatcherServlet</servlet-name>
		<url-pattern>*.hessian</url-pattern>
	</servlet-mapping>
package com.xx.service;

/**
 * 服务接口 
 */
public interface ISayHelloService {

	/**
	 * @param name
	 * @return
	 */
	 String doSayHello(String name);
	 
	/**
	 * @param name
	 * @param welcomeStr
	 * @return
	 */
	 String doSayHello(String name, String welcomeStr);
}
package com.xx.service.impl;

import com.xx.service.ISayHelloService;

/**
 * 服务接口实现 
 */
public class DefaultSayHelloServiceImpl implements ISayHelloService {

	public String doSayHello(String name) {
		return doSayHello(name, "hello");
	}

	public String doSayHello(String name, String welcomeStr) {
		return name + "," + welcomeStr;
	}
}

 

spring配置文件applicationContext-hessianServer.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
		default-lazy-init="false">
	
	<!-- 服务端 实现-->
	<bean id="sayHelloService" class="com.xx.service.impl.DefaultSayHelloServiceImpl" />
	
	<bean id="sayHelloService_hessianRPC" 	class="org.springframework.remoting.caucho.HessianServiceExporter" >
		<property name="service" 			ref="sayHelloService" />
		<!-- 服务接口 -->
		<property name="serviceInterface" 	value="com.xx.service.ISayHelloService" />
	</bean>
		
	<bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
		<property name="urlMap">
			<map>
				<entry key="/sayHelloService.hessian" 	value-ref="sayHelloService_hessianRPC" />
			</map>
		</property>
	</bean>	
</beans>

二:客户端 调用服务

package com.xx.service;

/**
 * 服务接口 
 */
public interface ISayHelloService {

	/**
	 * @param name
	 * @return
	 */
	 String doSayHello(String name);
	 
	/**
	 * @param name
	 * @param welcomeStr
	 * @return
	 */
	 String doSayHello(String name, String welcomeStr);
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
	
	<!-- 客户端 -->
	<bean id="sayHelloService"  class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
		<!-- 重载方法支持 不然会抛出异常  :Caused by: com.caucho.hessian.io.HessianProtocolException:  is an unknown code -->
		<property name="overloadEnabled"	value="true" />
		<property name="serviceUrl" 		value="http://localhost:8080/spring_hessian/sayHelloService.hessian" />
		<!-- 服务接口 -->
		<property name="serviceInterface" 	value="com.xx.service.ISayHelloService"/>
	</bean>
</beans>

 

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.xx.service.ISayHelloService;

public class ClientMain {
	
	public static void main(String[] args) {
		ISayHelloService sayHelloService = getBean(ISayHelloService.class, "sayHelloService");
		System.out.println(sayHelloService.doSayHello("王五"));
		//客户端必须启用重载方法支持  不然会抛出Caused by: com.caucho.hessian.io.HessianProtocolException: '�' is an unknown code异常
		System.out.println(sayHelloService.doSayHello("李四", "welcome"));
	}
	
	public static <T> T getBean(Class<T> clazs, String beanName) {
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext-client.xml");
		return clazs.cast(applicationContext.getBean(beanName));
	}
}

依赖的jar文件:


 

spring 整合Hessian Hessian服务暴露和服务调用 详细教程 源码地址 源码地址 1.Hessian使用的介绍 Hessian是一个轻量级的RPC框架,基于HTTP协议 1.1 服务端配置 三部曲 通过springMVC的DispatherServlet控制Hessian服务接口的URL访问路径 即web.xml配置 新建Hessian服务 例如:DemoService 和实现类 DemoServiceImpl 配置Hessian服务... 阅读详情

相关推荐

Spring 与Hessian 整合的简单远程调用实例

Spring与hessian 远程调用整合

xwh9004的博客 3186

解决hessian com.caucho.hessian.io.hessianprotocolexception 异常

现象项目中使用到hessian,调用到hessian服务端的含有重载方法的接口出现了如下错误: com.caucho.hessian.io.HessianProtocolException: is unknown code expected end of call (‘z’) at 0x4d (M). Check method arguments and ensure method o

morris 2万+

spring+hessian搭建rpc体系

如果用tomcat部署服务器,需要hessian的认证,请在E:\tomcat\apache-tomcat-7.0.69\conf\tomcat-users.xml下面配置信息:如下 <role rolename="Hessian"/> <user username="账号" password="密码" roles="Hessian"/>

解决Hessian调用重载方法报错问题(HessianProtocolException)

使用Hessian调用重载方法报异常问题,例如: [java] view plain copy String SayHello();          String SayHello(String name);   客户端调用上面的方法: [java] view plain copy IH

hpu_jxust的专栏 2359

学习笔记【Day 20】鸿蒙PC应用在SD WAN MSTP场景用CodeArts test工具测试过程

多生成树协议(MSTP)作为二层网络高可靠、无环路的核心技术,其在鸿蒙 PC 上的兼容性与稳定性测试尤为重要。本文结合华为云 CodeArts TestPlan 全流程测试管理平台,详细拆解鸿蒙 PC 端 MSTP 功能的测试设计、环境搭建、执行验证。1.测试左移,保障迭代效率CodeArts TestPlan 将 MSTP 测试从后期集成阶段 “左移” 至开发早期,通过可复用用例库与自动化脚本,支持每次代码提交后的快速回归测试,避免网络功能稳定性因迭代被破坏。2.平台化工具破解复杂场景测试难题。

aiyijianghe的博客 1058

Power Bi数据分析案例:在线零售平台销售数据分析

该数据集为,涵盖2023年1月至2024年3月,包含用户群体特征、购买行为、产品偏好以及参与度指标。用户维度:Customer_ID,Age,Gender,City产品维度:Product_Category,Unit_Price事实表:Order_ID,Quantity,Total_Amount,Discount_Amount,Rating,Delivery_Time在Power Query当中处理销售日期列,并新增年龄段、浏览页面分段列。

2301_79586168的博客 1278

Spring整合Hessian

前言:       近日着手研究了一下Hessian的rmi方案,因为客户端是多种移动终端平台,本来想采用传说中的phprpc(hprose?)的,但看了下官方的文档,发现没有object-c的版本,故而放弃。       跟着hessian 的官方例子走,跑起来是没有问题的,但我在试着跟spring整合的时候,出了不少的问题。记录一下,方便自己以及路人,呵呵。   环境说

专栏 3201

Visual Studio调试时遇到ntdll.dll的PDB文件缺失?别慌,这3个方法帮你搞定(附详细步骤)

本文详细解析了Visual Studio调试时ntdll.dll的PDB文件缺失问题,提供了3种实用解决方案:调整调试设置、配置符号服务器与缓存目录、手动下载管理符号文件。通过分步指导和高级技巧,帮助开发者快速恢复完整的调试功能,特别适用于Windows平台下的C++项目开发。

weixin_42537919的博客 513

Spring整合Hessian与分析

前言 上一篇文章Hessian入门体验与分析介绍了hessian的简单入门,并且从源码层面对Hessian的调用流程进行了分析;发现使用原生的Hessian还是比较繁琐的,下面看看Spring与Hessian进行整合并且进行简要分析。 使用 提供三个模拟块,分别模拟client,server以及被依赖的jar;对应的模块名称分别是:hessianClient,hessianServer以...

weixin_41140797的博客 1006

angular中访问本地json文件

先在assets文件夹下写一个json文件,这样在打完包之后也可以手动修改json文件内容 1、在需要访问本地json文件的ts文件里面引入 import{HttpClient}from'@angular/common/http'; 2、用ajax请求调用,我这里是用已经封装好的ajax请求调用 gethttp = ()=>{ var self = this self.ajax.getAjax("../../assets/server.json","g...

蜗牛~~ 1830

kaggle学习笔记-餐厅数据挖掘

分析Zomato数据集的基本思想是为了公平地了解影响在班加罗尔不同地方建立不同类型餐厅的因素,每个餐厅的总评级,班加罗尔是这样一个城市,拥有超过12,000家餐厅,餐厅供应来自世界各地的菜肴。每天都有新的餐馆开业,这个行业还没有饱和,需求也在与日俱增。然而,尽管需求不断增加,新餐馆却很难与老牌餐馆竞争。大多数餐厅都供应同样的食物。班加罗尔是印度的IT之都。这里的大多数人主要依靠餐馆的食物,因为他们没有时间自己做饭。由于对餐馆的需求如此巨大,因此研究一个地方的人口统计学就变得很重要。

优快云XXCQ的博客 1862

Spring整合Hessian访问远程服务

Spring整合Hessian访问远程服务 1.1     Hessian简介        Hessian是一个轻量级的Web服务实现工具,它采用的是二进制协议,因此很适合发送二进制数据。它的一个基本原理就是把远程服务对象以二进制的方式进行发送和接收。 1.2     整合 1.2.1 概述 对于Hessian而言,有服务端和客户端,所以我们的整合也需要分服务端的整合和客户

Elim的博客 1万+

PCL 基于强度的双边滤波【2026最新版】

基于强度信息的双边滤波代码实现、滤波前后点云未出现变化的原因以及获取带有强度pcd点云的方法。本文由优快云点云侠原创,博客长期更新,本文最近一次更新时间为:2026年5月24日。

点云侠的博客 29万+

java hessian spring_hessian demo和hessian与spring整合demo

package server.demo;public interface DemoApi {public void setName(String name);public String sayHello();public User getUser();}实现接口:package server.demo;public class DemoService implements DemoApi {pri...

weixin_33304777的博客 197

[Python] 为什么你的脚本明明没报错,却什么也没发生?

Python脚本运行后没报错却没结果?这是许多开发者遇到的棘手问题。文章分析了六种常见原因:代码未进入目标逻辑分支、输出路径错误、中间数据为空、异常被吞掉、异步操作未完成、运行了错误脚本版本。建议通过"过程可视化"排查,如打印关键变量、检查工作目录、验证数据状态等。职场中更应关注结果验证而非单纯代码执行,确保脚本真正解决问题。建立结果验证意识是从"会写代码"到"稳定交付"的关键转变。

技术小甜甜:传播可落地技术,帮助个人和企业降低解决真实场景问题的成本 303

【YOLOv11多模态涨点改进】独家创新首发 | TGRS 2025 | 引入CDFIM跨模态差异特征交互模块,通过差异特征提取和融合增强机制,减少了冗余信息,显著提升了小目标的检测精度,高效涨点改进

🔥本文给大家介绍使用 CDFIM跨模态差异特征交互模块改进 YOLOv11多模态目标检测,通过有效的差异特征提取和增强,显著提升了小目标的检测精度,特别是在复杂背景和低对比度环境下。该模块通过残差加法和通道与空间注意力机制,增强了可见光与红外模态之间的互补特征交互,减少了冗余信息,提高了检测稳定性。尽管提升了特征交互,CDFIM 仍保持轻量化设计,计算开销和参数量较低,适合实时检测应用。总的来说,CDFIM 模块在保留原始模态信息的同时优化了特征融合,有效提高了 YOLO 在多模态目标检测中的鲁棒性和精度

Ai缝合怪、助力小伙伴高效发论文 131

Spring整合Hessian教程

转载于:http://www.net0755.com/xt6643.html     Spring让Hessian变得不但强大,而且易用,但是易用背后,却有不少陷阱! 这个例子很简单,但实际上的确花费了我超过一小时的时间,排除了种种问题,最后问题终于水落石出。 整合以上篇Hello Hessian为基础,加入Spring框架,进行改进。 一、环境 jdk1.5 http   <!

zgmzyr的专栏 1432

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Spring与Hessian简单的整合

现在大部分的应用都使用到了Spring框架,我们一般使用Spring容器来管理对象的创建。我们同样可以将Hessian与Spring整合,方便管理,简化代码的开发。

您已进入防沉迷系统... 1628

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

java hession_Spring整合Hessian

[在Spring框架中使用Hessian,一般来说都是定义好Spring的转发器以后,把请求和配置好的bean名字(带斜杠)做对应然后依靠 HessianServiceExporter来得到对应� ...]Spring让Hessian变得不但强大,而且易用,但是易用背后,却有不少陷阱!这个例子很简单,但实际上的确花费了我超过一小时的时间,排除了种种问题,最后问题终于水落石出。整合以下篇Hell...

weixin_39621794的博客 166

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

spring整合hessian 转载

转载 原文地址:http://haohaoxuexi.iteye.com/blog/1869488 Spring整合Hessian访问远程服务 目录 1.1 Hessian简介 1.2 整合 1.2.1 概述 1.2.2 服务端整合 1.2.3 客户端整合 1.1 Hessian简介 Hessian是一个轻...

u012377366的博客 324

spring boot整合hessian

原博地址:http://www.jianshu.com/p/71df169bcf5e首先添加hessian依赖<dependency> <groupId>com.caucho</groupId> <artifactId>hessian</artifactId> <version>4.0.38</version> </dependenc

sias1991的专栏 1万+
上一篇: Hessian源码浅析-HessianProxy
下一篇: Struts2源码浅析-初始化
胸口碎大石_
博客等级 码龄17年 1154粉丝 82原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值