基于.NET Remoting框架的分布式系统构建
- 格式:pdf
- 大小:232.27 KB
- 文档页数:3
: .NET Remoting路 了不 路來 路來 力 理 類 利 理 異說 了不度 不行 來 力了 不契 利易 不路 來臨 路了 度 了 來來來 率了 立來率 了 了了量 了 更 率 度 例 行 來 不例 來 不 例 來 參 來 不 兩 不 類 例 利 來 例 了兩列 了 讀 參 來不路流量 路流量 行不理論行列 烈來說了兩來讀 例兩更 論了 兩說 兩立 理 連串論來參 更了 論說 不 來兩兩 類 見兩狀 不 狀說 兩狀 狀兩 不狀 不 不不 兩說 鍊Assembly) 立 來 數不 了來例連串 論 讀 了 念 來 練 例例 論 兩 念來 了 便 例 了來 立 來using System;namespace C64.Share{public interface IMyService{name);stringHelloService(string}}來 立立 來列using System;using C64.Share;namespace Server{public class MyService:MarshalByRefObject,IMyService{MyService():base()public{Created!");isConsole.WriteLine("ServiceObject}name)HelloService(stringpublicstring{return"+name;"Hello}}}了來Using System;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;using C64.Share;namespace Server{Startupclass{[STAThread]static void Main(string[] args){HttpChannel(1234);chnl=newHttpChannelChannelServices.RegisterChannel(chnl);RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService),"MyService.soap",WellKnownObjectMode.Singleton);ServerRunning...");System.Console.WriteLine("RemotingConsole.ReadLine();}}}立 論了了 了 類 立 兩 立立 來 不 立立 來 立 行 立 兩 來 行 論了 兩 來 讀 來 行例例來 理來 列using System;using System.Collections.Specialized;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;using C64.Share;namespace Client{Startupclass{SimpleBinding()IMyServicestatic{HttpChannel();chnl=newHttpChannelChannelServices.RegisterChannel(chnl);(IMyService)Activator.GetObject(typeof(IMyService),return"http://localhost:1234/MyService.soap");}[STAThread]static void Main(string[] args){bindingsimple//useobj=SimpleBinding();IMyServiceConsole.WriteLine(obj.HelloService("code6421"));Console.ReadLine();}}}立來論行來不 兩 立 行行 力類[Serializable]public class Person{public string Name;public int Age;}例public Person GetPerson(){Person data=new Person();="code6421";data.Age=18;return data;}行 理論兩行了Using System;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;using System.Runtime.Remoting.Channels.Tcp;using C64.Share;namespace Server{Startupclass{[STAThread]static void Main(string[] args){HttpChannel(1234);chnl=newHttpChannelChannelServices.RegisterChannel(chnl);TcpChannel chnl1=new TcpChannel(9012);ChannelServices.RegisterChannel(chnl1);RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService),"MyService.soap",WellKnownObjectMode.SingleCall);Running...");System.Console.WriteLine("RemotingServerConsole.ReadLine();}}}立來using System.Runtime.Remoting.Channels.Tcp;………..static IMyService SimpleBinding(){HttpChannel chnl=new TcpChannel();ChannelServices.RegisterChannel(chnl);return (IMyService)Activator.GetObject(typeof(IMyService),"tcp://localhost:9012/MyService.soap");}using System.Runtime.Remoting.Channels.Http;………..static IMyService SimpleBinding(){HttpChannel chnl=new HttpChannel();ChannelServices.RegisterChannel(chnl);return (IMyService)Activator.GetObject(typeof(IMyService),"http://localhost:1234/MyService.soap");}了立“ ”來利 來 參數 裡 立 兩using System;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;using System.Runtime.Remoting.Channels.Tcp;using System.Collections;using System.Collections.Specialized;using System.Runtime.Serialization.Formatters;using System.Runtime.Remoting.MetadataServices;using C64.Share;namespace Server{class Startup{[STAThread]static void Main(string[] args){new ListDictionary();=ListDictionaryHttpChannelProperties1234);HttpChannelProperties.Add("port",SoapClientFormatterSinkProvider soapClientSink=new SoapClientFormatterSinkProvider();BinaryClientFormatterSinkProvider binaryClientSink=new BinaryClientFormatterSinkProvider();soapClientSink.Next=binaryClientSink;SoapServerFormatterSinkProvidersoapServerSink=new SoapServerFormatterSinkProvider();binaryServerSink=newBinaryServerFormatterSinkProviderBinaryServerFormatterSinkProvider();SdlChannelSinkProvidersdlProvider=new SdlChannelSinkProvider();soapServerSink.Next=binaryServerSink;sdlProvider.Next=soapServerSink;HttpChannel chnl=new HttpChannel(HttpChannelProperties,soapClientSink,sdlProvider);ChannelServices.RegisterChannel(chnl);chnl1=new TcpChannel(9012);TcpChannelChannelServices.RegisterChannel(chnl1);RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService),"MyService.soap",WellKnownObjectMode.Singleton);System.Console.WriteLine("Remoting Server Running...");Console.ReadLine();}}}立了兩 連 來裡 立立 不了 立了力 了來static IMyService TcpSoapBinding(){ListDictionary prop=new ListDictionary();prop.Add("port",9013);chnl=new TcpChannel(prop,new SoapClientFormatterSinkProvider(),TcpChannelnew SoapServerFormatterSinkProvider());ChannelServices.RegisterChannel(chnl);return (IMyService)Activator.GetObject(typeof(IMyService),"tcp://localhost:9012/MyService.soap"); }static IMyService TcpBinaryBinding(){prop=new ListDictionary();ListDictionaryprop.Add("port",9013);chnl=new TcpChannel(prop,new BinaryClientFormatterSinkProvider(),TcpChannelnew BinaryServerFormatterSinkProvider());ChannelServices.RegisterChannel(chnl);return (IMyService)Activator.GetObject(typeof(IMyService),"tcp://localhost:9012/MyService.soap"); }static IMyService HttpSoapBinding(){ListDictionary properties=new ListDictionary();chnl=new HttpChannel(properties,new SoapClientFormatterSinkProvider(),HttpChannelnew SoapServerFormatterSinkProvider());ChannelServices.RegisterChannel(chnl);return (IMyService)Activator.GetObject(typeof(IMyService),"http://localhost:1234/MyService.soap"); }static IMyService HttpBinaryBinding(){properties=new ListDictionary();ListDictionaryHttpChannel chnl=new HttpChannel(properties,new BinaryClientFormatterSinkProvider(),new BinaryServerFormatterSinkProvider());ChannelServices.RegisterChannel(chnl);return (IMyService)Activator.GetObject(typeof(IMyService),"http://localhost:1234/MyService.soap"); }了 力了 來讀 量例不來 了 來論 了 便利利 來using System;using System.Runtime.Remoting;namespace Server{Startupclass{[STAThread]static void Main(string[] args){RemotingConfiguration.Configure("Server.exe.config");Running...");ServerSystem.Console.WriteLine("RemotingConsole.ReadLine();}}}了 來讀 讀了<?xml version="1.0" encoding="utf-8" ?><configuration><system.runtime.remoting><application><channels><channel ref="http" port="1234" /></channels><service><wellknown mode="Singleton" type="Server.MyService, Server"objectUri="MyService.soap" /></service></application></system.runtime.remoting></configuration>讀 例<?xml version=”1.0” encoding="utf-8" ?><configuration><system.runtime.remoting><application><channels><channel ref="http" port="1234" /><channel ref="tcp" port="9012" /></channels><service><wellknown mode="Singleton" type="Server.MyService, Server"objectUri="MyService.soap" /></service></application></system.runtime.remoting></configuration>利 來 理<?xml version="1.0" encoding="utf-8" ?><configuration><system.runtime.remoting><application><client><wellknown type="Share.IMyService,Share" url="http://localhost:1234/MyService.soap" /> </client><channels><channel ref="http" /></channels></application></system.runtime.remoting></configuration><?xml version="1.0" encoding="utf-8" ?><configuration><system.runtime.remoting><application><client><wellknown type="Share.IMyService,Share" url="tcp://localhost:9012/MyService.soap" /> </client><channels><channel ref="tcp" /></channels></application></system.runtime.remoting></configuration>利 來來來 理<?xml version="1.0" encoding="utf-8" ?><configuration><system.runtime.remoting><application><channels><channel ref="http" port="1234" ><serverProviders><provider ref="wsdl" /><formatter ref="soap" /><formatter ref="binary" /></serverProviders></channel><channel ref="tcp" port="9012" ><serverProviders><provider ref="wsdl" /><formatter ref="soap" /><formatter ref="binary" /></serverProviders></channel></channels><service><wellknown mode="Singleton" type="Server.MyService, Server" objectUri="MyService.soap" /> </service></application></system.runtime.remoting></configuration><?xml version="1.0" encoding="utf-8" ?><configuration><system.runtime.remoting><application><client><wellknown type="Share.IMyService,Share" url="http://localhost:1234/MyService.soap" /></client><channels><channel ref="http" /></channels><clientProviders><formatter ref="soap" /> or <formatter ref=”binary”/></clientProviders></application></system.runtime.remoting></configuration>了 來 錄 錄讀來力 來 行 來 例Unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;Edit1: TEdit;Edit2: TEdit;procedure Button1Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementationuses MyService;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);varRemotingObj:MyServicePortType;data:Person;beginRemotingObj:=GetMyServicePortType();Edit1.Text:=RemotingObj.HelloService('code6421');ShowMessage('Next');data:=RemotingObj.GetPerson;Edit1.Text:=;Edit2.Text:=IntToStr(data.Age);end;end.行來 行 不兩 立 來 立 不 了了 來 不 露立 了 來using System;namespace Share{public interface IMyFactory{getService();IMyService}///<summary>/// Summary description for Class1.///</summary>public interface IMyService{int State{get;set;}}}Using System;using Share;namespace Server{public class ServiceFactory:MarshalByRefObject,IMyFactory{public IMyService getService(){return new ServiceImpl();}}///<summary>/// Summary description for ServiceImpl.///</summary>public class ServiceImpl:MarshalByRefObject,IMyService{private int _state;public int State{get{return _state;}set{_state=value;}}}}using System;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;namespace Server{///<summary>/// Summary description for Class1.///</summary>class Startup{///<summary>/// The main entry point for the application.///</summary>[STAThread]static void Main(string[] args){chnl=new HttpChannel(1234);HttpChannelChannelServices.RegisterChannel(chnl);RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServiceFactory),"factory.soap",WellKnownObjectMode.Singleton); Console.ReadLine();}}}using System;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;using Share;namespace Client{///<summary>/// Summary description for Class1.///</summary>class Startup{///<summary>/// The main entry point for the application.///</summary>[STAThread]static void Main(string[] args){chnl=new HttpChannel();HttpChannelChannelServices.RegisterChannel(chnl);IMyFactoryfactory=(IMyFactory)Activator.GetObject(typeof(IMyFactory),"http://localhost:1234/factory.soap");obj1=factory.getService();IMyServiceobj2=factory.getService();IMyServiceobj1.State=15;obj2.State=30;Console.WriteLine("Object 1 State:{0}",obj1.State);Console.WriteLine("Object 2 State:{0}",obj2.State);Console.ReadLine();}}}行 讀 了 狀 不了 了更 見了。
基于NETRemoting的分布式系统设计
吴清寿
【期刊名称】《南平师专学报》
【年(卷),期】2005(24)4
【摘要】本文介绍了.NET 框架中基于.NET Remoting 分布式应用程序的体系结构及具体实现。
文中对.NET Remoting的构架特点进行了介绍。
并且结合实际的开发和麻用,给出了使用 c#实现的具体方法。
【总页数】4页(P58-60)
【关键词】分布式系统;Remoting;信道
【作者】吴清寿
【作者单位】南平师范高等专科学校计算机科学与工程系
【正文语种】中文
【中图分类】TP393.09
【相关文献】
1.一种基于分布式对象技术的分布式监控系统设计 [J], 王静;吴健
2.基于分布式虚拟磁盘的可扩展分布式文件系统设计 [J], 柴梦竹;
3.基于IEEE1588时间同步的分布式桥梁健康监测系统基于BQ76pl455高精度电压采集芯片的储能电池管理系统设计 [J], 李雄伟;季钰林;谢伊亮;陈永强;李英祥
4.基于分布式数据治理技术的声像数据处理系统设计与实现 [J], 张文磊
5.基于Hadoop的分布式财务异常数据分析系统设计 [J], 王金元;王宇;张亚松;林昊;龚致富;李盼;安新艳
因版权原因,仅展示原文概要,查看原文内容请购买。
基于.NET Remoting技术的分布式旅游管理平台设计与实现[摘要]本文首先阐述了.NET Remoting技术的基本原理和框架。
针对目前旅游行业的电子商务平台架构的缺陷,本文研究与设计了一套基于.NET Remoting技术的分布式旅游管理平台解决方案。
该平台基于多用户、高并发的特性,结合XML技术,使应用服务与Web服务器分离,为分布式的业务应用提供了高效可靠的架构。
最后,介绍了该平台的代码实现。
[关键词]旅游管理平台;分布式;.NET Remoting技术;XML技术0引言随着当今电子商务的快速发展和旅游行业业务的不断拓展,人们越来越依赖网络在线完成旅游相关事宜,这就给旅游行业的从业者提出了新问题。
当用户规模到达一定数量级时,原先的简单架构已经不能满足日益增长的用户群在线操作的需求,搭建一个稳健的、易扩展的旅游管理平台迫在眉睫。
本文针对目前普通的旅游行业电子商务平台架构的缺陷,研究与设计了一套性能较高、易于扩展的旅游管理平台解决方案,该管理平台通过基础数据和核心业务的发布与管理集成,再结合系统权限管理,实现旅游业务数据的及时性和共享性。
1.NET Remoting技术介绍1.1.NET Remoting概述.NET Remoting是微软公司推出的远程服务框架,是构建分布式应用程序的一种编程模式,它提供了在不同应用程序域之间通过调用远程对象而进行交互的技术框架,能使信息在不同计算机、进程间远程传输[1]。
1.2.NET Remoting技术框架.NET Remoting中的远程基础结构由代理(Proxy)、通道(Channel)和消息(Formatter)组成。
代理是指模仿远程对象的本地对象,通道对象代表了本程序到远程应用程序的连接,每个通道对象都包含了一个将方法调用转换为已知格式的消息格式化程序对象,然后将消息发送到远程服务器上,客户端通道对象镜像在这个服务器上可以侦听请求。
其技术框架如图1所示。
使用Remoting开发分布式应用——Remoting服务发布方式任旻微软特约讲师i-miren@个人简介本次课程Level 200Remoting 框架图System.Object(不可远程化)passed by reference(MarshalByRefObject)passed by valueServer-Activated(WellKnown)Client-Activated PublishedSingleton SingleCallRegisteredCreated by factory[Serializable]ISerializable本次课程内容包括本次课程内容包括l使用应用程序发布Ø控制台ConsoleØWin Form控制台程序Win FormApplication ServerClient Application ServerClient本节的DemoJob ManagerDEMO本次课程内容包括l通过Windows服务发布Ø创建Windows服务工程Ø安装Windows服务开发Windows服务Windows服务的安装installutilJobWindowsService.exeWindows服务的安装Windows服务installutilJobWindowsService.exeDEMO本次课程内容包括l通过IIS发布Ø好处Ø实现方法使用IIS发布Remoting服务实现方法<configuration><system.runtime.remoting><application><service><wellknownmode="Singleton"type= "JobServerLib.JobServerImpl,JobServerLib"objectUri="JobServer.soap" /></service></application></system.runtime.remoting></configuration>DEMO本次课程内容包括l元数据的相关性应减少客户端和服务器的耦合度JobClient.exe JobServer.exeJobServerLib.dll IJobServer JobServerImpl JobServerLib.dll IJobServer JobServerImpl应减少客户端和服务器的耦合度JobClient.exe JobServer.exeJobInterface.dllIJobServer JobServerLib.dllJobServerImpl JobInterface.dll IJobServer总结获取更多MSDN资源l MSDN中文网站/china/msdnl MSDN中文网络广播l MSDN Flash/china/newsletter/case/ l MSDN开发中心/china/msdn/DeveloperQuestion & Answer。