web service上remoting问题
在已经在使用的web service建立一个remote object,主要是另外子系统需要和当前子系统做同步工作.
Web service作为服务器端,在Application_Start()里激活remote object.
BinaryClientFormatterSinkProvider Prc = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider Prv = new BinaryServerFormatterSinkProvider();
Prv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
Hashtable prop = new Hashtable();
prop["port"] = 8085;
IChannelReceiver Ch = new TcpChannel(prop, Prc, Prv);
ChannelServices.RegisterChannel(Ch);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingCore.RemoteServer),"WebService.SyncCache", WellKnownObjectMode.SingleCall);
在客户端:
public void SyncCache()
{
RemoteServer syncCache = (RemotingCore.RemoteServer)Activator.GetObject(typeof(RemotingCore.RemoteServer), "tcp://localhost:8085/WebService.SyncCache"); //返回不为null
string ret = syncCache.SayHello(); //出错
}
出错信息: System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.
BTW: SayHello只是简单返回一个string的过程.