简体   繁体   中英

WCF WPF Silverlight wsDualHttpBinding pollingDuplexHttpBinding

I'm fighting hours on hours to get this Silverlight duplex to work but fail after fail ,

I have A)WCF Service Appllication B) WPF Client C) Silverlight Client ( Do I need +host ?! )

I connect successfully A<=>B - working good , my problem is A<=>C (Silverlight Duplex Client)

  • Can I have 2 endpoints somehow ? wsDualHttpBinding & pollingDuplexHttpBinding ? Tried and fail

An endpoint configuration section for contract 'Service2.IService1' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

  • Can pollingDuplexHttpBinding works on WPF ?

  • Help ! Thanks !

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

So yes It's possible more than 2 endpoints :

Step I :

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

Step II :Very Important : WCF Cross Domain SecurityException

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

Step III :

Silverlight Client :

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

WPF Client :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM