积极答复者
WCF的双工通讯问题,如何设置客户端接受Callback的端口

问题
-
WCF的双工通讯问题,我用一个控制台应用程序作为服务端的HOST,用WSDualHttpBinding(支持双工)进行绑定,客户端调用服务端的OneWay方法,客户端代码如下:
System.ServiceModel.EndpointAddress ea =
new EndpointAddress("http://localhost:8889/WcfServiceLibrary/TestService");
System.ServiceModel.WSDualHttpBinding binding =
new WSDualHttpBinding();
System.ServiceModel.InstanceContext ic =
new InstanceContext(new WpfApplication1.CallbackHandler());
WpfApplication1.TestService.TestServiceClient sc =
new WpfApplication1.TestService.TestServiceClient(ic,binding, ea);
string data = sc.Greet(this.textBox1.Text);
System.Windows.MessageBox.Show(data);
sc.TestOneWayMethod(data);但是跑出异常,异常类型是 AddressAlreadyInUseException ,并提示TCP 80 端口正在被使用。显然,客户端尝试在80端口上进行监听,而80端口已经被IIS占用了。
请问我如何设置客户端的监听端口以避免冲突?
- 已移动 微软中文技术论坛Moderator 2009年5月20日 0:25 ([Loc]From:.NET Framework 相关)
答案
-
你可以通过代码的方式,手工指定一个可用的端口
参考http://news.newhua.com/news1/program_language/2007/1119/071119105931KFBDH7DJ588CEH67IKI1.html
全部回复
-
WCF的双工通讯问题,我用一个控制台应用程序作为服务端的HOST,用WSDualHttpBinding(支持双工)进行绑定,客户端调用服务端的OneWay方法,客户端代码如下:
System.ServiceModel.EndpointAddress ea =
new EndpointAddress("http://localhost:8889/WcfServiceLibrary/TestService");
System.ServiceModel.WSDualHttpBinding binding =
new WSDualHttpBinding();
System.ServiceModel.InstanceContext ic =
new InstanceContext(new WpfApplication1.CallbackHandler());
WpfApplication1.TestService.TestServiceClient sc =
new WpfApplication1.TestService.TestServiceClient(ic,binding, ea);
string data = sc.Greet(this.textBox1.Text);
System.Windows.MessageBox.Show(data);
sc.TestOneWayMethod(data);但是跑出异常,异常类型是 AddressAlreadyInUseException ,并提示TCP 80 端口正在被使用。显然,客户端尝试在80端口上进行监听,而80端口已经被IIS占用了。
请问我如何设置客户端的监听端口以避免冲突?
-
WCF的双工通讯问题,我用一个控制台应用程序作为服务端的HOST,用WSDualHttpBinding(支持双工)进行绑定,客户端调用服务端的OneWay方法,客户端代码如下:
System.ServiceModel.EndpointAddress ea =
new EndpointAddress("http://localhost:8889/WcfServiceLibrary/TestService");
System.ServiceModel.WSDualHttpBinding binding =
new WSDualHttpBinding();
System.ServiceModel.InstanceContext ic =
new InstanceContext(new WpfApplication1.CallbackHandler());
WpfApplication1.TestService.TestServiceClient sc =
new WpfApplication1.TestService.TestServiceClient(ic,binding, ea);
string data = sc.Greet(this.textBox1.Text);
System.Windows.MessageBox.Show(data);
sc.TestOneWayMethod(data);但是跑出异常,异常类型是 AddressAlreadyInUseException ,并提示TCP 80 端口正在被使用。显然,客户端尝试在80端口上进行监听,而80端口已经被IIS占用了。
请问我如何设置客户端的监听端口以避免冲突?
-
你可以通过代码的方式,手工指定一个可用的端口
参考http://news.newhua.com/news1/program_language/2007/1119/071119105931KFBDH7DJ588CEH67IKI1.html