Raymond Leung

一方净土,成就你我。 [ PowerBuilder8.0 + Informix ====>> C#/Java + Oracle10g/SQLServer2000/PostgreSQL8.0 ]
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

不清楚要解决的问题,请看这里:

http://www.cnblogs.com/weko/archive/2004/12/20/79632.html#FeedBack

 

问题主要出在客户端,具体如下:
1.定义正确的http通道后
     HttpChannel channel = new HttpChannel();    
     ChannelServices.RegisterChannel(channel);
     channel = (HttpChannel)ChannelServices.GetChannel("http");
2.加入下面的话句

    WebProxy wp = GlobalProxySelection.Select as WebProxy;     //获取机器默认的proxy服务器变量
    wp.Credentials = CredentialCache.DefaultCredentials;               //将机器上默认的信任传入刚才指定的proxy服务器变量
    SetChannelProxy(channel,wp);                                                //将上面建好的proxy服务器变量传入到已定义的channel中

private static void SetChannelProxy( HttpChannel channel, IWebProxy proxy ) {
   FieldInfo clientChannelFieldInfo = typeof(HttpChannel).GetField("_clientChannel",BindingFlags.Instance | BindingFlags.NonPublic);
   HttpClientChannel clientChannel = (HttpClientChannel)clientChannelFieldInfo.GetValue(channel);
   FieldInfo proxyObjectFieldInfo = typeof(HttpClientChannel).GetField("_proxyObject",BindingFlags.Instance | BindingFlags.NonPublic);
   proxyObjectFieldInfo.SetValue( clientChannel, proxy );
  }
3.再建立连接通道
     FI_RecordingsManager = (IRecordingsManager) Activator.GetObject(typeof(IRecordingsManager),"http://"+CPSERVERIP+":"+CPSERVERPORT_HTTP.ToString()+"/RM");