Spring 远程调用 HTTP invoker
2013-01-14 17:07
477 查看
Spring HTTP invoker是spring框架中的一个远程调用模型,执行基于HTTP的远程调用(意味着可以通过防火墙),并使用java的序列化机制在网络间传递对象。
所以所有的pojo类必须实现序列化接口
client:
<bean id="rciClientService"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="serviceUrl">
<value>
${rci.service.url}/oprisk/kor/servlet/rciHttpService
</value>
</property>
<property name="serviceInterface">
<value>
com.citi.oprisk.kor.service.IRCIClientService
</value>
</property>
</bean>
build.xml:
<path id="compileClasspath">
<pathelement path="${ejbclient.dir}/RCI_client.jar" />
</path>
*-remote-call.properties:
rci.service.url=http://localhost:9080
sever:
<bean id="rciHttpService"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter" >
<property name="service">
<ref bean="rciClientService" />
</property>
<property name="serviceInterface"
value="com.citi.oprisk.kor.service.IRCIClientService">
</property>
</bean>
<bean id="rciClientService"
class="com.citi.oprisk.kor.service.RCIClientService">
<property name="korMaintainService">
<ref bean="korMaintainService" />
</property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true" />
<property name="mappings">
<props>
<prop key="/servlet/rciHttpService">rciHttpService</prop>
</props>
</property>
</bean>
build.xml:
<target name="rciClientJar" depends="init,compile">
<jar jarfile="${distDir}/RCI_client.jar"
basedir="${javaClassDir}">
<include name="com/citi/oprisk/kor/service/IRCIClientService.class"/>
......
</jar>
</target>
步骤:
1. 创建一个HTTP invoker服务输出者类(HttpInvokerServiceExporter)
2. 创建一个HTTP代理(使用HttpInvokerProxyFactoryBean)。你要细化这个类里的参数像serviceUrl和serviceInterface。
3. 为客户端调用远程HTTP服务定义一个URL映射。
4. 配置Spring beans。
5. 在web。xml文件里配置Spring Web层(DispatcherServlet)。
6. 写客户类(使用HTTP或者Commons HttpClient)。
所以所有的pojo类必须实现序列化接口
webservice | HTTP invoker |
跨平台,跨语言 | 只支持java语言 |
支持SOAP,提供wsdl | 不支持 |
结构庞大,依赖特定的webservice实现,如xfire等 | 结构简单,只依赖于spring框架本身 |
<bean id="rciClientService"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="serviceUrl">
<value>
${rci.service.url}/oprisk/kor/servlet/rciHttpService
</value>
</property>
<property name="serviceInterface">
<value>
com.citi.oprisk.kor.service.IRCIClientService
</value>
</property>
</bean>
build.xml:
<path id="compileClasspath">
<pathelement path="${ejbclient.dir}/RCI_client.jar" />
</path>
*-remote-call.properties:
rci.service.url=http://localhost:9080
sever:
<bean id="rciHttpService"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter" >
<property name="service">
<ref bean="rciClientService" />
</property>
<property name="serviceInterface"
value="com.citi.oprisk.kor.service.IRCIClientService">
</property>
</bean>
<bean id="rciClientService"
class="com.citi.oprisk.kor.service.RCIClientService">
<property name="korMaintainService">
<ref bean="korMaintainService" />
</property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true" />
<property name="mappings">
<props>
<prop key="/servlet/rciHttpService">rciHttpService</prop>
</props>
</property>
</bean>
build.xml:
<target name="rciClientJar" depends="init,compile">
<jar jarfile="${distDir}/RCI_client.jar"
basedir="${javaClassDir}">
<include name="com/citi/oprisk/kor/service/IRCIClientService.class"/>
......
</jar>
</target>
步骤:
1. 创建一个HTTP invoker服务输出者类(HttpInvokerServiceExporter)
2. 创建一个HTTP代理(使用HttpInvokerProxyFactoryBean)。你要细化这个类里的参数像serviceUrl和serviceInterface。
3. 为客户端调用远程HTTP服务定义一个URL映射。
4. 配置Spring beans。
5. 在web。xml文件里配置Spring Web层(DispatcherServlet)。
6. 写客户类(使用HTTP或者Commons HttpClient)。
相关文章推荐
- Spring HttpInvoker远程调用的例子
- Spring远程调用HTTP invoker
- 远程服务调用之RMI、Hessian、Burlap、Spring的HTTPinvoker
- Spring中HttpInvoker远程方法调用总结
- Spring与远程调用RMI、Hessian、Burlap、HttpInvoker、Jax-WS
- Spring的Hessian,Burlap,HttpInvoker远程调用
- [转载]spring的httpInvoker远程调用 示例
- Spring远程调用HttpInvoker
- Spring中HttpInvoker远程方法调用总结
- 使用Spring HTTP invoker进行远程调用
- Spring远程调用技术<3>-Spring的HTTP Invoker
- spring HTTP invoker:实现远程调用
- Spring中HttpInvoker远程方法调用总结
- Spring HttpInvokerProxyFactoryBean 远程调用示例
- Spring HTTP Invoker-远程调用模式
- Spring中HttpInvoker远程方法调用使用实例
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务的方法(推荐)
- 《Spring技术内幕》学习笔记17——Spring HTTP调用器实现远程调用
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- 《pro Spring》学习笔记之Spring HTTP 远程方法调用