1

我正在努力工作几个小时才能让这个 Silverlight 双工工作,但一次又一次失败,

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

我成功连接 A<=>B - 工作正常,我的问题是 A<=>C (Silverlight Duplex Client)

  • 我可以以某种方式拥有 2 个端点吗?wsDualHttpBinding 和 pollingDuplexHttpBinding ?尝试并失败

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

  • pollingDuplexHttpBinding 可以在 WPF 上工作吗?

  • 帮助 !谢谢 !

网络配置

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

4

1 回答 1

0

所以是的,可能有超过 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");
于 2012-08-22T07:55:58.633 回答