remoting

 

三部分:

远程对象(类)

服务端(调用远程对象类)

客户端(调用远程对象类)

远程对象

其中remoting类继承MarshalByRefObject

服务端(客户端激活模式)

//定义通道端口

       int http_port =8010;

 

以下为服务器有双网卡的情况下,需指定服务器URI的具体地址时使用(--包括内)

--

//创建服务端的Provider

SoapServerFormatterSinkProvider provider = new SoapServerFormatterSinkProvider();

//设置Provider的TypeFilterLevel,黙认为Low,可设为Full

provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Low;

 

Hashtable props = new Hashtable();

props["port"] = http_port;

props["machineName"] = 192.168.1.10;

//建立通道

HttpChannel channel = new HttpChannel(props,null,

provider);

--

否则可直接建立通道

HttpChannel channel = new HttpChannel(http_port);

 

//注册通道

ChannelServices.RegisterChannel(channel,false);

 

//注册对象

RemotingConfiguration.ApplicationName = "HealthMid";

RemotingConfiguration.RegisterActivatedServiceType(typeof(RemoteStatus));

 

注:网上查到,最好用客户端激活模式,原因不详

注:TCPHTTPIDictionary接口不同:

TCPBinaryClientFormatterSinkProvider()BinaryServerFormatterSinkProvider()

HTTPSoapClientFormatterSinkProvider()与SoapServerFormatterSinkProvider()

 

客户端(客户端激活模式)

string Remote_Url = http://192.168.1.10:8010/HealthMid;

 

HttpChannel channel = new HttpChannel();

ChannelServices.RegisterChannel(channel);

 

RemotingConfiguration.RegisterActivatedClientType(typeof(RemoteStatus), Remote_Url);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值