我有点时间搞清楚这一点。我有一个WCF服务,我需要向Silverlight客户端提供信息,但我需要一个控制台应用程序也能够参与其中。任何人都可以给我一个暗示我的Web.Config应该是什么样子来指定控制台应用程序可以访问的附加绑定?当我认为我的工作正常时,SL客户端无法接收任何消息......
这是我目前的Web.Config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Create the polling duplex binding. -->
<bindings>
<pollingDuplex>
<binding name="myPollingDuplex"
duplexMode="MultipleMessagesPerPoll">
</binding>
</pollingDuplex>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name ="EdiManager.Web.EdiPubSub">
<endpoint address=""
binding="pollingDuplex"
bindingConfiguration="myPollingDuplex"
contract="EdiManager.Web.EdiPubSub"
/>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
</system.serviceModel>
</configuration>
答案 0 :(得分:1)
如果您不需要全双工,只需使用wsHttpBinding而不是mex(或提供更多信息,您想要实现的目标)。
答案 1 :(得分:1)
您是否希望控制台应用程序也参与轮询双工连接?或者您想要使用不同的查询 - 响应绑定吗?
另外,我注意到您使用AspNetCompatibility进行轮询双工。如果您正在访问会话状态,则会遇到一些性能问题。我做了一个关于它的short blog post,它引用了一个带有测试信息的MSDN blog post。
简而言之,轮询双工是一种长时间超时操作。会话状态锁定,并且在轮询超时之前以及在再次锁定会话状态提供程序的另一个连接之前,没有其他请求可以继续。
答案 2 :(得分:0)
我能够通过使用WCF服务编辑器编辑配置而不是手动执行它来使其工作。显然我手动编辑配置时出错了。这是有效的web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Create the polling duplex binding. -->
<bindings>
<wsDualHttpBinding>
<binding name="myDualHttp" />
</wsDualHttpBinding>
<pollingDuplex>
<binding name="myPollingDuplex" duplexMode="MultipleMessagesPerPoll" />
</pollingDuplex>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="EdiManager.Web.EdiPubSub">
<endpoint address="Silverlight" binding="pollingDuplex" bindingConfiguration="myPollingDuplex"
name="Silverlight" contract="EdiManager.Web.EdiPubSub" />
<endpoint address="Console" binding="wsDualHttpBinding" bindingConfiguration="myDualHttp"
name="Console" contract="EdiManager.Web.EdiPubSub" />
</service>
</services>
</system.serviceModel>
</configuration>