簡體   English   中英

WCF WPF Silverlight wsDualHttpBinding pollingDuplexHttpBinding

[英]WCF WPF Silverlight wsDualHttpBinding pollingDuplexHttpBinding

為了使這個Silverlight雙工正常工作,我一直在努力奮斗,但是一次又一次失敗,

我有A)WCF服務應用程序B)WPF客戶端C)Silverlight客戶端(我需要+ host嗎?!)

我成功連接了A <=> B-工作正常,我的問題是A <=> C(Silverlight Duplex Client)

  • 我可以以某種方式有2個端點嗎? wsDualHttpBinding和pollingDuplexHttpBinding嗎? 嘗試並失敗

無法找到合同“ Service2.IService1”的端點配置部分,因為找到了該合同的多個端點配置。 請按名稱指示首選端點配置部分。

  • 可以在WPF上使用pollingDuplexHttpBinding嗎?

  • 救命 ! 謝謝 !

Web配置

<!-- 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" />

所以是的,可能有兩個以上的端點:

步驟一:

<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>

步驟II:非常重要:WCF跨域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");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM