您的位置:首页 > 编程语言 > Java开发

spring整合hessain 访问远程服务

2014-03-20 18:12 399 查看
1. 首先加入hessain.jar包

<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>4.0.7</version>
</dependency>


2. 如果是服务端需要配置web.xml

<servlet>
<servlet-name>hession</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:hession-web.xml
classpath*:hession-config.xml
</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>hession</servlet-name>
<url-pattern>/hession/*</url-pattern>
</servlet-mapping>


3. 服务端hessain.-web.xml配置

<bean name="/openService" class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service" ref="openServiceImpl" />
<property name="serviceInterface" value="com.open.service.OpenService" />
</bean>


4. 客户端调用openService

<bean id="openService"  class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl" value="http://localhost/hessain/openService" />
<property name="serviceInterface" value="com.open.service.openService" />
</bean>


客户端只要openService的interface
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: