在 IIS 7 (WAS) 中托管 WCF 服务,并在两个 tcp 端口上绑定 net.tcp
默认情况下,IIS 7 网站具有带有“808:”绑定信息字符串的 net.tcp 绑定。如果我添加另一个带有“xxx:”的 net.tcp 绑定,则会发生异常:
此集合已包含具有方案 net.tcp 的地址。该集合中的每个方案最多可以有一个地址。 参数名称:item
我该如何解决这个问题并在两个端口监听我的服务?
By default IIS 7 Web site has net.tcp binding with "808:" binding information string. If i add another net.tcp binding with "xxx:" exception occurs:
This collection already contains an address with scheme net.tcp. There can be at most one address per scheme in this collection.
Parameter name: item
How can i solve this problem and listen my service at TWO ports?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本上,在您的服务中,您应该能够在任意数量的端口上定义任意数量的服务端点。
有两种方法可以执行此操作:
如果您选择选项#1,您将有这样的内容:
所以在这种情况下,同一个合约有两个服务端点,它们将监听 URL
,并且
您可以有多个服务端点,但只能有一个基地址。
另一种选择是不指定基地址并直接在端点中指定完整服务地址:
在这种情况下,由于您在端点中定义整个地址,因此您可以选择两个不同的 TCP 端口,每个端点一个。这应该没有任何问题。您在两个单独的端口上有两个单独的端点,它们在后台侦听并由同一服务类提供服务。
马克
Basically, in your service, you should be able to define any number of service endpoints on any number of ports.
There's two ways to do this:
If you do option #1, you'll have something like this:
So in this case, you have two service endpoints for the same contract, and they'll be listening on URLs
and
You can have mulitple service endpoints, but only one base address.
The other option is to specify no base addresses and specify your full service address in the endpoint directly:
In this case, since you're defining the whole address in the endpoint, you can pick two different TCP ports, one for each endpoint. This should work with no problem at all. You have two separate endpoints on two separate ports, both listening and being serviced by the same service class in the background.
Marc
前几天,我试图将 WCF 服务部署到我的一台 Web 服务器上,但遇到了问题。我不断收到以下错误消息:p>
该集合已包含一个带有 http 方案的地址。此集合中每个方案最多可以有一个地址。参数名称:item
该问题并未发生在我的本地计算机上,而是发生在 Web 服务器上,这使得找出导致该问题的原因有点困难。它发生在服务器上,因为我的 Web 服务器位于共享托管环境中,在这种情况下,WCF 服务还需要知道主机标头。为此,我导航到 web.config 并添加了以下内容:
I was trying to deply a WCF service to one of my web servers the other day and ran into a problem. I kept getting the following error message:p>
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.Parameter name: item
The problem didn't happen on my local machine but did on the web server making it a little difficult to figure out what was causing it. It happened on the server because my web server is in a shared hosting environment in which case the WCF service also needs to know the host header. To do this I navigated to in the web.config and added the following:
又是我。
这适用于自主机
,但使用 IIS7+WAS 会导致异常
无法连接到 net.tcp://localhost:12345/game2.svc。连接尝试持续的时间跨度为 00:00:02.0936160。 TCP错误代码10061:无法建立连接,因为目标机器主动拒绝127.0.0.1:12345。
问题是关于IIS托管环境
Its me again.
This works with self host
but with IIS7+WAS cause exception
Could not connect to net.tcp://localhost:12345/game2.svc. The connection attempt lasted for a time span of 00:00:02.0936160. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:12345.
The question was about IIS hosting environment