使用Spring httpinvoker 远程调用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Spring httpinvoker 远程调用相关的知识,希望对你有一定的参考价值。

服务器端:

spring.xml 中添加:

<bean id="aboutUsService"  class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">  
        <property name="service" > 
            <bean class="com.XXX.XXX.service.impl.XXXX" />  
        </property>
        <property name="serviceInterface" value="com.XXX.XXX.service.XXXService" />
    </bean>

服务器端 web.xml 中添加:

<servlet>
        <servlet-name>aboutUsService</servlet-name>
        <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>aboutUsService</servlet-name>
        <url-pattern>/as</url-pattern>
    </servlet-mapping>

服务器端 web.xml 中,servlet-name 需要与spring.xml中的bean id一致,否则会报错,找不到该 id

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

在网上查找资料,使用的是:

 

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="/aboutUs.service">aboutUsServiceInvoker</prop>
            </props>
        </property>
    </bean>

 

报的是

技术分享

 

 

不知道什么原因,哪位大神看到,可以帮忙解释下。。。

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

客户端:

<bean id="aboutUsServiceProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
        <property name="serviceUrl" value="http://127.0.0.1:8080/emart/as" />
        <property name="serviceInterface" value="com.XXX.XXX.service.AboutUsService" />
    </bean>

这里需要注意项目中的过滤器,不过滤/as的请求。

如有错误,请大神在评论区指示!!!!!!

 

以上是关于使用Spring httpinvoker 远程调用的主要内容,如果未能解决你的问题,请参考以下文章

java RPC系列之二 HTTPINVOKER

spring源码学习spring的远程调用实现源码分析

Spring远程服务(RPC)

SpringHttpInvoker解析1-使用示例

使用远程服务

sping揭秘25Spring远程方案