当前位置: 代码迷 >> Web Service >> web service上remoting有关问题
  详细解决方案

web service上remoting有关问题

热度:282   发布时间:2012-03-03 15:33:04.0
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的过程.

------解决方案--------------------
remoting调试起来很麻烦啊
------解决方案--------------------
你改成Http通道试下

IChannelReceiver Ch = new HttpChannel(prop, Prc, Prv);
------解决方案--------------------
应该是需要调用一下webservice的方法才能运行app_start的代码
最好不在webservice里做这个
------解决方案--------------------
为什么要在web服务中用remoting?
  相关解决方案