现在的位置: 首页 > 综合 > 正文

Spring发布和使用Http Invoker

2013年11月01日 ⁄ 综合 ⁄ 共 1279字 ⁄ 字号 评论关闭

Spring发布和使用Http Invoker

假设我们的业务接口是PayMentService,实现类是PayMentServiceImpl
1.发布Http Invoker
 
<beam id="httpPayMentService" class="org.spingframework.remoting.httpinvoker.HttpInvokerServiceExporter">
   <property name="service">
      <bean class="org.springinaction.service.PayMentServiceImpl">
   <property>
   <property name="serviceInterface">
      <bean class="org.springinaction.service.PayMentService">
   <property>
</bean>

同时,还需要设置urlMapping
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleHandlerMapping">
   <property name="mappings">
       <props>
          <prop key="/pay.service">httpPayMentService</prop>
       <props>
   </property>
</bean>

然后在web.xml配置映射
<servlet>
  <servlet-name>credit</servlet-name>
  <servlet-class>rg.springframework.web.servlet.DispatchServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
 <servlet-name>credit</servlet-name>
 <url-pattern>*.service<url-pattern>
</servlet-mapping>

2.使用HttpInvoker
<bean id="paymentService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactpryBean">
    <property name="serviceUrl">
       <value>http://${serverBame}/${contextPAth}/pay.service</value>
    </property>
    <property name="serviceInterface">
      <bean class="org.springinaction.service.PayMentService">
    </property>
</bean> 

抱歉!评论已关闭.