浅尝Hessian远程调用

2024-02-26 02:32
文章标签 调用 远程 hessian 浅尝

本文主要是介绍浅尝Hessian远程调用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Hessian是一个远程调用的技术,hessian由两个部分组成,服务端和客户端,服务端供客户端调用。下面先上一个小例子,然后再作一个简单的说明。

服务端项目结构图:
这里写图片描述

HelloService接口代码:

public interface HelloService {public void hello();}

HelloServiceImpl实现类代码:

@Service("helloService")public class HelloServiceImpl implements HelloService {@Overridepublic void hello() {System.out.println("hello hession !");}}

spring相关的配置文件

<bean id="helloService" class="com.hession.HelloServiceImpl"/> <bean name="/hello"  class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="helloService"/> <property name="serviceInterface" value="com.hession.HelloService"/> </bean>

项目中导入hessian包,在web.xml配置hessian的servlet-mapping

<servlet-mapping><servlet-name>dispatcher</servlet-name><url-pattern>*.html</url-pattern><url-pattern>*.json</url-pattern><url-pattern>*.xml</url-pattern><url-pattern>*.jhtml</url-pattern><url-pattern>*.do</url-pattern><url-pattern>/hessian/*</url-pattern>(配置hessian路径)
</servlet-mapping>

客户端:
这里写图片描述

HelloService接口和服务端的一致,HessianClient代码如下:

public class HessionClient {public static void main(String[] args) {//具体路径根据服务端的配置改变而改变  String url="http://localhost:8182"+"/hessian/hessian/hello";HessianProxyFactory pf = new HessianProxyFactory();HelloService hello = null;try {hello = (HelloService)pf.create(HelloService.class,url);hello.hello();} catch (MalformedURLException e) {e.printStackTrace();}}} 

运行main方法即可调用服务端的业务。

这篇关于浅尝Hessian远程调用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/747470

相关文章

如何在页面调用utility bar并传递参数至lwc组件

1.在app的utility item中添加lwc组件: 2.调用utility bar api的方式有两种: 方法一,通过lwc调用: import {LightningElement,api ,wire } from 'lwc';import { publish, MessageContext } from 'lightning/messageService';import Ca

【LabVIEW学习篇 - 21】:DLL与API的调用

文章目录 DLL与API调用DLLAPIDLL的调用 DLL与API调用 LabVIEW虽然已经足够强大,但不同的语言在不同领域都有着自己的优势,为了强强联合,LabVIEW提供了强大的外部程序接口能力,包括DLL、CIN(C语言接口)、ActiveX、.NET、MATLAB等等。通过DLL可以使用户很方便地调用C、C++、C#、VB等编程语言写的程序以及windows自带的大

string字符会调用new分配堆内存吗

gcc的string默认大小是32个字节,字符串小于等于15直接保存在栈上,超过之后才会使用new分配。

京东物流查询|开发者调用API接口实现

快递聚合查询的优势 1、高效整合多种快递信息。2、实时动态更新。3、自动化管理流程。 聚合国内外1500家快递公司的物流信息查询服务,使用API接口查询京东物流的便捷步骤,首先选择专业的数据平台的快递API接口:物流快递查询API接口-单号查询API - 探数数据 以下示例是参考的示例代码: import requestsurl = "http://api.tanshuapi.com/a

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef‘ of undefined“

vue 父组件调用子组件的方法报错,“TypeError: Cannot read property ‘subDialogRef’ of undefined” 最近用vue做的一个界面,引入了一个子组件,在父组件中调用子组件的方法时,报错提示: [Vue warn]: Error in v-on handler: “TypeError: Cannot read property ‘methods

远程工具-SecureCRT/SecureFX

下载地址: https://www.portablesoft.org/securecrt-securefx-integrated/

【微服务】Ribbon(负载均衡,服务调用)+ OpenFeign(服务发现,远程调用)【详解】

文章目录 1.Ribbon(负载均衡,服务调用)1.1问题引出1.2 Ribbon负载均衡1.3 RestTemplate整合Ribbon1.4 指定Ribbon负载均衡策略1.4.1 配置文件1.4.2 配置类1.4.3 定义Ribbon客户端配置1.4.4 自定义负载均衡策略 2.OpenFeign面向接口的服务调用(服务发现,远程调用)2.1 OpenFeign的使用2.1 .1创建

类和对象的定义和调用演示(C++)

我习惯把类的定义放在头文件中 Student.h #define _CRT_SECURE_NO_WARNINGS#include <string>using namespace std;class student{public:char m_name[25];int m_age;int m_score;char* get_name(){return m_name;}int set_name

React 笔记 父子组件传值 | 父组件调用子组件数据 | defaultProps | propsType合法性验证

1.通过props实现父组件像子组件传值 、方法、甚至整个父组件 传递整个父组件则   [变量名]={this} import Header from "./Header"render(){return(<Header msg={"我是props传递的数据"}/>)} import React,{Component} from "react";class Header extends