日期:2014-05-20  浏览次数:20842 次

WCF + SilverLight4 + WPF 的疑难了
1、网站页面用SilverLight4开发,
2、与数据库通信用WCF
3、客户端还包含一部分WPF开发的WinForm程序,与数据库的通信仍然用WCF。
4、WCF宿主为网站的IIS
5、要求服务器与SilverLight4与WPF皆可双工通信
问题:
网页的SilverLight4与WCF通信没有任何问题。
但WPF的WinForm窗口与WCF通信存在故障,

约定协议接口IService声明如下:
    [ServiceContract(CallbackContract = typeof(IServiceCallBack))]
    public interface IService
    { 
       [OperationContract]
        void Func(string  msg);

    }
客户端回调协议接口如下:
    public interface IServiceCallBack
    {
        [OperationContract(IsOneWay = true)] 
        void ServerSendMessage(string arg);
    }
当然,网站中具体的服务实现过程WCFService.svc这里就不列举了,无非就是函数代码而已,
这里仅列出结构:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)] 
public class WCFService : QBox.IService
{
//此处省略不写代码了
}


由此,网站的Web.config配置如下:
<?xml version="1.0"?>
<configuration> 
<system.serviceModel>
    <behaviors>
<serviceBehaviors>
<behavior name="QBox.WCFServiceBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceTimeouts transactionTimeout="10:11:00"/> 
          <serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="1000"/> 
          <serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="QBox.WCFServiceBehavior" name="WCFService">
<endpoint address="" binding="pollingDuplexHttpBinding" bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding" contract="QBox.IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
</services>
<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>
      <pollingDuplexHttpBinding>
        <binding  name="multipleMessagesPerPollPollingDuplexHttpBinding" duplexMode="MultipleMessagesPerPoll" maxOutputDelay="00:00:00"   maxBufferPoolSize="2147483647"  maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"  />
        </binding>