可以用WEB SERVICE 和.NET REMOTING,这方面例子很多,网上很容易找到
解决方案 »
- .net 截取字符串只有substring吗?
- 一个关于socket的问题
- C#的static和C++的static有什么区别
- 关于监控硬盘 只需提示一下即可!
- 为什么Combobox显示很慢
- 请问c#中Winform得控件TextBox怎么实现换行?一行一行得写进去??
- C#.NET我用jquery写的动态添加和删除,保存的时候不会写了。求大神解决,在线等。请在 btnSaveClick() 补充代码,万分感谢了。
- 高手帮着看看这个问题怎么解决
- 安装包制作
- C#发布post问题
- 100分求解水晶报表连续打印问题,也就是不分页打印?
- 求救:datagrid编辑完毕后,页面能否停留在当前编辑行?
参考:
http://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A
第一个是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封装的消息送到服务器端,最后的到返回。