通过Spring.net发布Remoting

简介: Spring.Services程序集中提供了对Remoting的支持,使用Spring.net可以方便的发布和使用Remoting服务。1.Remoting发布(服务端) (1)首先在config文件中注册通道:                                 ...

   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对象。

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

目录
相关文章
.NET Remoting学习笔记(二)激活方式
原文:.NET Remoting学习笔记(二)激活方式 目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道   参考:百度百科  风车车.Net   激活方式概念 在访问远程类型的一个对象实例之前,必须通过一个名为Activation的进程创建它并进行初始化。
1147 1
|
网络协议 数据安全/隐私保护 网络架构
.NET Remoting学习笔记(三)信道
原文:.NET Remoting学习笔记(三)信道 目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道   参考:风车车.Net   .NET Framework 远程处理基础结构提供下列信道实现: IpcChannel TcpChannel HttpChannel IpcChannel IPCChannel是.NET Framework 2.0 里面新增的,它使用 Windows 进程间通信 (IPC) 系统在同一计算机上的应用程序域之间传输消息。
1060 0
|
网络协议 安全 C#
.Net Remoting(远程方法回调) - Part.4
.Net Remoting(远程方法回调) - Part.4 Remoting中的方法回调 1. 远程回调方式说明 远程方法回调通常有两种方式: 客户端也存在继承自MarshalByValueObject的类型,并将该类型的实例作为参数传递给了远程对象的方法,然后远程对象在其方法中通过该类型实例的引用对它进行调用(访问其属性或者方法)。
701 0
.Net Remoting(远程方法回调) - Part.4
|
网络安全 Windows 数据库
.Net Remoting的双向通信和Windows Service的宿主服务
原文:.Net Remoting的双向通信和Windows Service的宿主服务      作为微软分布式技术之一的.Net Remoting,从性能、安全等各方面来说都是相对比较稳定的,也是一项比较成熟的分布式技术。
1038 0
|
网络协议 网络架构
.Net中Remoting通信机制
原文:.Net中Remoting通信机制 Remoting通信机制 Remoting介绍 主要元素 通道类型 激活方式 对象定义 Remoting介绍 什么是Remoting,简而言之,我们可以将其看作是一种分布式处理方式。
970 0
|
C# 网络协议
.Net中Remoting通信机制简单实例
原文:.Net中Remoting通信机制简单实例 .Net中Remoting通信机制 前言: 本程序例子实现一个简单的Remoting通信案例     本程序采用语言:c#   编译工具:vs2013工程文件   编译环境:.
915 0
|
网络协议
.NET Remoting学习笔记(一)概念
原文:.NET Remoting学习笔记(一)概念 目录 .NET Remoting学习笔记(一)概念 .NET Remoting学习笔记(二)激活方式 .NET Remoting学习笔记(三)信道  背景 自接触编程以来,一直听过这个名词Remoting,但是对他了解少之又少,近日有点时间,参考研究研究。
1253 0