WCF - HTTP无法注册URL http:// +:80/
问题描述:
我的第一篇文章在*上!WCF - HTTP无法注册URL http:// +:80/
我遇到了一些问题,我正在尝试构建WCF服务,我需要一些帮助才能弄明白。
服务有两部分,第一部分是一个非常简单的REST风格的Web服务,它充满了GET方法,这很好。
下一个区域是一个Pub/Sub模型,它基本上会向内部用户推送来自第一个区域的特定调用方法的结果。为了合并这个,我在两个端点上侦听,现在每次我在PubSub服务上调用一个方法时,我都会收到上述错误。在搜索interwebulator后,我看到很多帖子都说默认情况下IIS使用的是80端口。
现在两个问题:1。 我的服务是基于以下的基地址听,无关80 http://localhost:3526/TradePortal和http://localhost:3526/TradePortal/Operations 2.我理想中的IIS
举办这次的建议是我改变客户端基地址不使用端口80,而是在服务器端或客户端配置中设置。
我对这个解决方案有点困惑,我之前已经使用NetTCP作为绑定构建了一个pubsub模型。
任何线索,如何解决这个,将不胜感激
服务器侧配置:
<system.serviceModel>
<services>
<service behaviorConfiguration="Default" name="CFP_Web_Lib.TradePortal">
<host>
<baseAddresses>
<add baseAddress="http://localhost:3526/TradePortal"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding"
contract="CFP_Web_Lib.ITradePortal"
behaviorConfiguration="web"
/>
<endpoint address="Operations/" binding="wsDualHttpBinding"
contract="CFP_Web_Lib.ITradeOperations"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
客户端代码(由VS2010自动生成)
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ITradeOperations" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3526/TradePortal/Operations/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ITradeOperations"
contract="CFP_Web.ITradeOperations" name="WSDualHttpBinding_ITradeOperations">
<identity>
<userPrincipalName value="[email protected]" />
</identity>
</endpoint>
</client>
</system.serviceModel>
答
问题是客户端不是服务器。 WsDualHttpBinding
使用两个连接 - 一个从客户端到服务器,另一个从服务器到客户端(以支持回调)。这就是它被称为双重的原因。为了允许连接客户端公开自己的服务器(回调实现)。该服务还必须具有一些地址和未使用的端口。如果您不指定此地址,默认情况下它将使用端口80,这很可能已被IIS使用。您必须在客户端更改此地址。使用绑定配置的clientBaseAddress
属性。