我需要在 web.config 中修复哪些内容才能使此 MSDN 示例正常工作?

发布于 2024-10-26 02:07:13 字数 2948 浏览 4 评论 0原文

在 Visual Studio 2010 中使用 .NET 4 和 Silverlight 4,我尝试按照 MSDN 指南为 Silverlight 客户端构建双工服务 (http://msdn.microsoft.com/en-us/library/cc645027(v=vs.96).aspx)。

Web.config 给出警告:

警告 26 元素“绑定”具有无效的子元素 'pollingDuplexHttpBinding'。预期可能的元素列表: 'basicHttpBinding、customBinding、msmqIntegrationBinding、 netPeerTcpBinding、netMsmqBinding、netNamedPipeBinding、netTcpBinding、 wsFederationHttpBinding、ws2007FederationHttpBinding、wsHttpBinding、 ws2007HttpBinding、wsDualHttpBinding、netTcpContextBinding、 wsHttpContextBinding、basicHttpContextBinding、mexHttpBinding、 mexHttpsBinding、mexNamedPipeBinding、mexTcpBinding、 webHttpBinding'。 C:\DuplexService\DuplexService\Web.config

我无法将服务引用添加到客户端。我无法在 WCF 测试客户端中加载该服务。我在很多地方寻找答案。我不明白问题出在哪里。

web.config 目前看起来像这样:

<!-- Register the binding extension from the SDK. -->
<extensions>
  <bindingExtensions>
    <add name=
        "pollingDuplexHttpBinding"
        type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </bindingExtensions>
</extensions>

<bindings>
  <!-- Create the polling duplex binding. -->
  <pollingDuplexHttpBinding>
    <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
             duplexMode="MultipleMessagesPerPoll"
             maxOutputDelay="00:00:07"/>
  </pollingDuplexHttpBinding>
</bindings>

<services>
  <service name="DuplexService.OrderService"
     behaviorConfiguration="DuplexService.OrderServiceBehavior">

    <!-- Service Endpoints -->
    <endpoint
       address=""
       binding="pollingDuplexHttpBinding"
       bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
       contract="DuplexService.IDuplexService">
    </endpoint>
    <endpoint
        address="mex"
        binding="mexHttpBinding"
        contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- 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>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

Using .NET 4 and Silverlight 4 in Visual Studio 2010, I am trying to follow the MSDN guide to build a duplex service for a Silverlight client (http://msdn.microsoft.com/en-us/library/cc645027(v=vs.96).aspx).

Web.config gives warning:

Warning 26 The element 'bindings' has invalid child element
'pollingDuplexHttpBinding'. List of possible elements expected:
'basicHttpBinding, customBinding, msmqIntegrationBinding,
netPeerTcpBinding, netMsmqBinding, netNamedPipeBinding, netTcpBinding,
wsFederationHttpBinding, ws2007FederationHttpBinding, wsHttpBinding,
ws2007HttpBinding, wsDualHttpBinding, netTcpContextBinding,
wsHttpContextBinding, basicHttpContextBinding, mexHttpBinding,
mexHttpsBinding, mexNamedPipeBinding, mexTcpBinding,
webHttpBinding'. C:\DuplexService\DuplexService\Web.config

I am unable to add the Service Reference to the client. I am unable to load the service in WCF Test Client. I have looked for answers in many places. I don't see what the problem is.

The web.config currently looks like this:

<!-- Register the binding extension from the SDK. -->
<extensions>
  <bindingExtensions>
    <add name=
        "pollingDuplexHttpBinding"
        type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </bindingExtensions>
</extensions>

<bindings>
  <!-- Create the polling duplex binding. -->
  <pollingDuplexHttpBinding>
    <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
             duplexMode="MultipleMessagesPerPoll"
             maxOutputDelay="00:00:07"/>
  </pollingDuplexHttpBinding>
</bindings>

<services>
  <service name="DuplexService.OrderService"
     behaviorConfiguration="DuplexService.OrderServiceBehavior">

    <!-- Service Endpoints -->
    <endpoint
       address=""
       binding="pollingDuplexHttpBinding"
       bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
       contract="DuplexService.IDuplexService">
    </endpoint>
    <endpoint
        address="mex"
        binding="mexHttpBinding"
        contract="IMetadataExchange"/>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- 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>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瀟灑尐姊 2024-11-02 02:07:13

我也有这个问题。通过添加

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll

到 WebRole 项目的引用解决了这个问题。

I also had this issue. Solved this by adding

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll

to the References of the WebRole project.

各自安好 2024-11-02 02:07:13

使用这个配置...它对我有用。

<system.serviceModel>
<extensions>
  <bindingElementExtensions>
    <add name="pollingDuplex"
         type="System.ServiceModel.Configuration.PollingDuplexElement, 
         System.ServiceModel.PollingDuplex" />
  </bindingElementExtensions>
</extensions>
<bindings>
  <customBinding>
    <binding name="pollingDuplexBinding">
      <binaryMessageEncoding />
      <pollingDuplex maxPendingSessions="2147483647"   
                     maxPendingMessagesPerSession="2147483647" 
                     />
      <httpTransport />
    </binding>
  </customBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="sb">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceThrottling maxConcurrentSessions="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="DataServices" behaviorConfiguration="sb" >
    <endpoint address="" 
              binding="customBinding" 
              bindingConfiguration="pollingDuplexBinding"
              contract="DataServices.IDataService"/>
    <endpoint address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange"/>
  </service>
</services>

Use this config... it works for me.

<system.serviceModel>
<extensions>
  <bindingElementExtensions>
    <add name="pollingDuplex"
         type="System.ServiceModel.Configuration.PollingDuplexElement, 
         System.ServiceModel.PollingDuplex" />
  </bindingElementExtensions>
</extensions>
<bindings>
  <customBinding>
    <binding name="pollingDuplexBinding">
      <binaryMessageEncoding />
      <pollingDuplex maxPendingSessions="2147483647"   
                     maxPendingMessagesPerSession="2147483647" 
                     />
      <httpTransport />
    </binding>
  </customBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="sb">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceThrottling maxConcurrentSessions="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="DataServices" behaviorConfiguration="sb" >
    <endpoint address="" 
              binding="customBinding" 
              bindingConfiguration="pollingDuplexBinding"
              contract="DataServices.IDataService"/>
    <endpoint address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange"/>
  </service>
</services>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文