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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值