注意事项

▲JAVA服务器端必须具备以下几点:
---->包含Hessian的jar包
---->设计一个接口,用来给客户端调用
---->实现该接口的功能
---->配置web.xml,配好相应的servlet
---->对象必须实现Serializable 接口
---->对于复杂对象可以使用Map的方法传递

▲客户端必须具备以下几点:
---->java客户端包含Hessian.jar的包。C#中引用hessianCSharp.dll
---->具有和服务器端结构一样的接口。包括命名空间都最好一样
---->利用HessianProxyFactory调用远程接口。
服务器端(向外暴漏接口的应用)
【1】配置该web应用的web.xml文件

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
 3      <!-- 以下3项参数与log4j的配置相关 -->
 4      <!-- start -->           
 5     <context-param>     
 6         <param-name>log4jConfigLocation</param-name>     
 7         <param-value>/WEB-INF/log4j.properties</param-value>     
 8     </context-param>     
 9           
10     <context-param>     
11         <param-name>log4jRefreshInterval</param-name>     
12         <param-value>60000</param-value>     
13     </context-param>     
14     <listener>     
15         <listener-class>     
16              org.springframework.web.util.Log4jConfigListener      
17         </listener-class>     
18     </listener>     
19     <!-- end -->     
20   
21   <!-- 一个web.xml中可以配置多个DispatcherServlet,通过 servlet-mapping的不同设置,让每个DispatcherServlet处理不同的请求-->
22   
23   <!-- 业务层和持久层的bean的spring配置文件。applicationContext.xml.多个配置文件使用,号隔开-->
24   <context-param>
25       <param-name>contextConfigLocation</param-name>
26       <param-value>classpath:/spring-mybatis/spring-mybatis.xml</param-value>
27   </context-param>
28   
29   <!-- 配置Spring监听 。通过contextConfigLocation配置的xml文件启动业务层(service和dao)的bean的容器。【service层和dao层的容器】-->
30   <!-- spring的监听器 -->
31     <listener>
32         <description>spring监听器</description>
33         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
34     </listener>
35 
36 
37   <!-- 暴露hessian接口的servlet -->
38   <servlet>
39         <servlet-name>hessian</servlet-name>
40         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
41         <!-- 此处加载的hessin-servlet.xml必须是该格式【servlet的名字】-servlet.xml。如果非该格式,报错 -->
42         <init-param>  
43             <param-name>contextConfigLocation</param-name>  
44             <param-value>classpath:/hessian-remote/hessian-servlet.xml</param-value>  
45         </init-param>  
46         <load-on-startup>1</load-on-startup>
47     </servlet>
48 
49     <servlet-mapping>
50         <servlet-name>hessian</servlet-name>
51         <url-pattern>/hessian/*</url-pattern>
52     </servlet-mapping>
53   
54 
55   </web-app>
View Code

相关文章:

  • 2021-08-14
  • 2021-10-22
  • 2022-12-23
  • 2021-06-18
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-02
  • 2021-12-27
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-08-30
相关资源
相似解决方案