• 通过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继承,而且还要设置生存期,否则可能出现在服务端回调的时候出现“找不到对应的服务”的错误。

  • 相关阅读:
    小数在计算机中的存储形式
    pyenv、virtualenv、virtualenvwrapper三种python多版本介绍
    【转】【WPF】WPF中MeasureOverride ArrangeOverride 的理解
    【转】Visual Studio团队资源管理器 Git 源码管理工具简单入门
    C#客户端(WinForm)开机自动启动实现
    C# 使用XPath解析网页
    【C#】使用DWM实现无边框窗体阴影或全透窗体
    【转】【Centos】centos 安装libtorrent/rtorrent
    【Centos】【Python3】yum install 报错
    【Python】Centos + gunicorn+flask 报错ImportError: No module named request
  • 原文地址:https://www.cnblogs.com/zhuweisky/p/760581.html
Copyright © 2020-2023  润新知