我爱Aspx >> Asp.Net >> Microsoft .NET Remoting:技术概述(二)以下我们将举一个使用channel的例子。在这个例子中,我们将可以看到使用HTTP channel把两个应用
连接在一起是如此的简单。以下的服务器应用提供了一个服务,可将一个字符串的字母顺序反转。
Server.cs using System;
using System.IO;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.HTTP;
namespace RemotingSample
{
public class Reverser : MarshalByRefObject
{
public string Reverse(string text)
{
Console.WriteLine("Reverse({0})", text);
string rev = "";
for (int i=text.Length-1; i>=0; i--)
{
rev += text[i];
}
Console.WriteLine("returning : {0}", rev);
return rev;
}
}
public class TheApp
{
public static void Main()
{
file:// Create a new HTTP channel that
// listens on port 8000
HTTPChannel channel = new HTTPChannel(8000);
// ReGISter the channel with the runtime
ChannelServices.ReGISterChannel(channel);
// Expose the Reverser object from this server
RemotingServices.RegisterWellKnownType(
"server", // assembly name
"RemotingSample.Reverser", // full type name
"Reverser.soap", file:// URI
WellKnownObjectMode.Singleton // instancing mode
);
// keep the server running until
// the user presses enter
Console.WriteLine("Server.exe");
Console.WriteLine("Press enter to stop server...");
Ҷƪл˵?
Microsoft .Net Remoting系列专题..[05-15]
.NET Framework中的串行化操作[05-15]
.Net Remoting与Server 对象详解[05-15]
解析.Net框架下的序列化机制[05-15]
微软 .NET Remoting体系结构评估[05-15]
ASP.NET创建Web服务之使用事务[05-15]
ASP.NET创建Web服务之发布和部署[05-15]
HTTP 安全性和 ASP.NET Web 服务[05-15]
运用VB.net创建Web服务访问程序[05-15]
ASP.NET服务器端异步Web方法[05-15]
Remoting事件机制续[05-15]
Remoting和Web服务的区别[05-15]
Microsoft .Net Remoting系列专题..[05-15]
如何解决Remoting无法传输存储过..[05-15]
.NET Framework中的串行化操作[05-15]
.Net Remoting与Server 对象详解[05-15]
解析.Net框架下的序列化机制[05-15]
微软 .NET Remoting体系结构评估[05-15]
remoting使用手记[05-15]
[Remoting]当client不复存在而Re..[05-15]