zoukankan      html  css  js  c++  java
  • 通过Spring.net发布Remoting

       Spring.Services程序集中提供了对Remoting的支持,使用Spring.net可以方便的发布和使用Remoting服务。

    1.Remoting发布(服务端)
    (1)首先在config文件中注册通道:

    <system.runtime.remoting>
        
    <application>
          
    <channels>
            
    <channel ref="tcp" port="8100" >
              
    <serverProviders>
                
    <provider ref="wsdl" />
                
    <formatter ref="soap" typeFilterLevel="Full" />
                
    <formatter ref="binary" typeFilterLevel="Full" />
              
    </serverProviders>
              
    <clientProviders>
                
    <formatter ref="binary" />
              
    </clientProviders>
            
    </channel>
          
    </channels>
        
    </application>
      
    </system.runtime.remoting>


    (2)通过配置发布Remoting对象:
       这里我们以SAO的方式发布Remoting对象。

          <object id="gamesBoard" type="GameRabbit.Platform.Management.GamesBoard,GameRabbit.Platform">
          
    </object>

          
    <object name="saoGamesBoard" type="Spring.Remoting.SaoExporter,Spring.Services">
            
    <property name="TargetName" value="gamesBoard" />
            
    <property name="ServiceName" value="GamesBoard" />
          
    </object>


    (3)在程序启动时,初始化Remoting配置:

          RemotingConfiguration.Configure("EntityTest.exe.config");



    2.Remoting订阅(客户端)

         <object name="remoteGamesBoard" type="Spring.Remoting.SaoFactoryObject, Spring.Services">
            
    <property name="ServiceInterface">
              
    <value>GameRabbit.Platform.Management.IGamesBoard, GameRabbit.Platform</value>
            
    </property>
            
    <property name="ServiceUrl">
              
    <value>tcp://localhost:8100/GamesBoard</value>
            
    </property>
          
    </object>


    说明:(2008-07-16)
    1.Spring发布的remoting对象不需要从MarshalByRefObject继承,也不需要设置remoting对象的生存期(spring将其设为无限长)。Spring采用为对象添加动态代理的方式来做到这点。
    2.如果是注册到服务器然后用于回调的Remoting对象,必须从MarshalByRefObject继承,而且还要设置生存期,否则可能出现在服务端回调的时候出现“找不到对应的服务”的错误。

  • 相关阅读:
    HTML特殊字符编码对照表(备记)
    【java线程】锁机制
    java判断一个字符串是否为空,isEmpty和isBlank的区别
    对Java中properties类的理解
    使用redis的zset实现高效分页查询(附完整代码)
    ServiceStack.Redis高效封装和简易破解
    3.NetDh框架之缓存操作类和二次开发模式简单设计(附源码和示例代码)
    2.NetDh框架之简单高效的日志操作类(附源码和示例代码)
    1.NetDh框架之数据库操作层--Dapper简单封装,可支持多库实例、多种数据库类型等(附源码和示例代码)
    SQL Server索引原理解析
  • 原文地址:https://www.cnblogs.com/zhuweisky/p/760581.html
Copyright © 2011-2022 走看看