2010-11-05 63 views
1

我有一段时间弄清楚了这一点。我有一个WCF服务,我需要向Silverlight客户端提供信息,但是我需要一个控制台应用程序也能够参与此项。任何人都可以给我一个提示,告诉我的Web.Config应该看起来像指定控制台应用程序可以访问的附加绑定?当我觉得我得到的东西的工作的SL客户端将无法收到任何消息......WCF轮询双面绑定和非Silverlight客户端

这里是我当前的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> 

回答

1

如果您不需要全双工只是使用替代的wsHttpBinding mex(或提供更多信息,你想达到什么目的)。

+0

我知道这是我需要做的。问题是当我添加一个新的终端时,Silverlight客户端失聪,所以我希望有人可能会展示如何创建端点。我不知道我做错了什么。但我正在手动编辑配置。在星期六,当我再次尝试使用WCF服务编辑器时,它工作正常。所以我只需要记下我缺乏的技能!还是)感谢你的建议。 – 2010-11-08 13:54:54

1

您是否希望控制台应用程序还参与轮询双工连接?或者你想使用不同的查询 - 响应绑定?

此外,我注意到你使用AspNetCompatibility与轮询双工。如果您访问会话状态,您将遇到一些性能问题。我做了一个关于它的short blog post,它引用了一个带有测试信息的MSDN blog post

简而言之,轮询双工是一个长时间超时操作。会话状态锁定,并且在轮询超时之前和其他连接再次锁定会话状态提供程序之前,不会执行其他任何请求。

+0

谢谢,Erik。你的博客文章很有趣。 – 2010-11-09 14:46:38

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>