web service上remoting问题

cenlmmx cenlmmx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在已经在使用的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的过程.
...全文
评论 8
收藏 已收藏
分享
返回顶部
cenlmmx
Web Services 12,164 成员 16,322 内容