【问题标题】:WCF WPF Silverlight wsDualHttpBinding pollingDuplexHttpBindingWCF WPF Silverlight wsDualHttpBinding pollingDuplexHttpBinding
【发布时间】:2012-08-21 14:23:45
【问题描述】:

为了让这个 Silverlight 双工能够正常工作,我一直在努力工作,但失败后又失败了,

我有 A)WCF 服务应用 B) WPF 客户端 C) Silverlight 客户端(我需要 +host 吗?!)

我连接成功 AB - 工作正常,我的问题是 AC (Silverlight Duplex Client)

  • 我可以有 2 个端点吗? wsDualHttpBinding 和 pollingDuplexHttpBinding ?尝试并失败

无法加载合同“Service2.IService1”的端点配置部分,因为找到该合同的多个端点配置。请按名称指明首选端点配置部分。

  • pollingDuplexHttpBinding 可以在 WPF 上工作吗?

  • 帮助!谢谢!

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>

<client>
  <endpoint address="http://localhost:8732/Service1/" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBinding" contract="TheWCFService.IService1" name="WSDualHttpBinding_Service1" />
</client>

<bindings>

  <wsDualHttpBinding>
    <binding name="wsDualHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </wsDualHttpBinding>

  <pollingDuplexHttpBinding>
    <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
             duplexMode="MultipleMessagesPerPoll"
             maxOutputDelay="00:00:07"/>
  </pollingDuplexHttpBinding>

</bindings>



<services>

  <service behaviorConfiguration="" name="TheWCFService.Service1">

    <endpoint address="" 
              binding="wsDualHttpBinding" 
              bindingConfiguration="wsDualHttpBinding" 
              contract="TheWCFService.IService1">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>

    <endpoint 
      address="mex"
      binding="mexHttpBinding" 
      bindingConfiguration="" 
      contract="IMetadataExchange" />

    <!--<endpoint
       address="/2"
       binding="pollingDuplexHttpBinding"
       bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
       contract="TheWCFService.IService1">
    </endpoint>-->

    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/Service1/" />
      </baseAddresses>
    </host>

  </service>
</services>

<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" />
      <serviceThrottling maxConcurrentSessions="500" maxConcurrentCalls="500" maxConcurrentInstances="500" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

【问题讨论】:

    标签: wcf silverlight


    【解决方案1】:

    所以是的,有可能超过 2 个端点:

    第一步:

    <endpoint address="wsDualHttpBinding" 
                      binding="wsDualHttpBinding" 
                      bindingConfiguration="wsDualHttpBinding" 
                      contract="TheWCFService.IService1">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
    
            <endpoint 
              address="mex"
              binding="mexHttpBinding" 
              bindingConfiguration="" 
              contract="IMetadataExchange" />
    
            <endpoint
               address="pollingDuplexHttpBinding"
               binding="pollingDuplexHttpBinding"
               bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
               contract="TheWCFService.IService1">
            </endpoint>
    
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8732/Service1/" />
              </baseAddresses>
            </host>
    

    第二步:非常重要:WCF Cross Domain SecurityException

    http://www.itscodingtime.com/post/Silverlight-to-WCF-Cross-Domain-SecurityException.aspx

    第三步:

    Silverlight 客户端:

                var x = new WCFService.Service1Client(
                        new PollingDuplexHttpBinding { DuplexMode = PollingDuplexMode.MultipleMessagesPerPoll, },
                        new EndpointAddress(@"http://localhost:59732/Service1.svc/pollingDuplexHttpBinding")
                        );
    

    WPF 客户端:

    >  _objProxy = new Service1Client(new InstanceContext(this),
    > "WSDualHttpBinding_IService1");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-30
      • 2011-01-04
      • 2011-09-07
      • 1970-01-01
      • 2012-12-26
      相关资源
      最近更新 更多