可以用WEB SERVICE 和.NET REMOTING,这方面例子很多,网上很容易找到

解决方案 »

  1.   

    建议用Remoting技术吧,现在我只要用到多台机器通讯,一般都用Remoting
      

  2.   

    用Soap协议,你可以直接用WEB SERVICE
    参考:
    http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A
      

  3.   

    不好意思,不知道是不是我说的不太清楚,我说的是两台服务器,在两个城市,现在要用SOAP方式把一个文件传到另一个服务器上去,而不是上传下载。有没有解决的方法?
      

  4.   

    自己的问题自己解决,现将解决的代码公布如下,大家看看有无问题:
    第一个是DLL文件;
    lizi1.cs
    using System;public interface ISimpleObject{
    String ToUpper(String inString);
    } 第二个是服务器文件;
    lizi2.csusing System;
    using System.Runtime.Remoting;
    using System.Runtime.Remoting.Channels;
    using System.Runtime.Remoting.Channels.Http; public class SimpleObject:MarshalByRefObject,ISimpleObject{
    public String ToUpper(String inString){
    Console.WriteLine("Send String is "+inString);
    return(inString.ToUpper());
    }
    }
    class lizi2{
    public static void Main(){
    HttpChannel hchan = new HttpChannel(154);
    ChannelServices.RegisterChannel(hchan);
    Type SimpleObjectType = Type.GetType("SimpleObject"); RemotingConfiguration.RegisterWellKnownServiceType(SimpleObjectType,"SOEndPoint",WellKnownObjectMode.Singleton);
    Console.WriteLine("press enter to halt server");
    Console.ReadLine();
    }
    }第三个是客户端文件
    lizi3.cs
    using System;
    using System.Runtime.Remoting;
    using System.Runtime.Remoting.Channels;
    using System.Runtime.Remoting.Channels.Http;class lizi3{
    public static void Main(){
    HttpChannel hchan = new HttpChannel(0);
    ChannelServices.RegisterChannel(hchan);
    Object remoteObject = RemotingServices.Connect(typeof(ISimpleObject),"http://localhost:154/SOEndPoint"); ISimpleObject so = remoteObject as ISimpleObject;

    Console.WriteLine(so.ToUpper("make this uppercase"));
    }
    }在编译的时候需要先把lizi1编译成DLL文件如:csc /t:libraty lizi1.cs
    然后编译服务器端成EXE如:csc /r:System.Runtime.Remoting.dll /r:lizi1.dll lizi2.cs
    最后编译客户端成EXE如:csc /r:System.Runtime.Remoting.dll /r:lizi1.dll lizi3.cs
    这样就可以跑了,而且是通过HTTP将SOAP封装的消息送到服务器端,最后的到返回。