2012-01-21 27 views
1

我有一個承載WCF服務的Windows服務。我也有一個連接到它的客戶端,消息來回發送。當我從客戶端發送消息到服務時,客戶端捕獲以下消息:WCF服務客戶端「服務器沒有提供有意義的回覆...」異常

服務器沒有提供有意義的答覆;這可能是由於合同不匹配,會話過早關閉或內部服務器錯誤造成的。

這有點奇怪,因爲我不希望服務直接回復客戶端發送的消息。服務成功獲取消息,但客戶端拋出此異常,似乎失去了與服務的連接。

這裏是服務app.config。忽略了一些關於REST類型的服務:

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
    <services> 
     <service name="OSAERest.api" behaviorConfiguration="MyServiceBehavior"> 
     <endpoint address="http://localhost:8732/api" 
        binding="webHttpBinding" 
        contract="OSAERest.IRestService" 
        behaviorConfiguration="WebHttp"/> 
     </service> 
     <service name="WCF.WCFService" behaviorConfiguration="WCFBehavior"> 
     <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WCFBinding" contract="WCF.IWCFService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint 
      address="mex" 
      binding="mexHttpBinding" 
      bindingConfiguration="" 
      contract="IMetadataExchange"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     <behavior name="WCFBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
      <serviceTimeouts transactionTimeout="05:05:00" /> 
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" 
      maxConcurrentInstances="2147483647" /> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="WebHttp"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <wsDualHttpBinding> 
     <binding name="WCFBinding"> 
      <security mode="None"> 
      </security> 
     </binding> 
     </wsDualHttpBinding> 

    </bindings> 
    </system.serviceModel> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <probing privatePath="lib" /> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

這裏是客戶端的app.config:

<?xml version="1.0"?> 
<configuration> 
    <appSettings> 

    <add key="ServiceIP" value="127.0.0.1"/> 


    </appSettings> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <probing privatePath="lib" /> 
    </assemblyBinding> 
    </runtime> 
    <system.serviceModel> 
    <bindings> 
     <wsDualHttpBinding> 
     <binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:01:00" 
      clientBaseAddress="http://localhost:8733/Design_Time_Addresses/WCF/WCFService/" 
      openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:10" 
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" /> 
      <security mode="None"> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" /> 
      </security> 
     </binding> 
     </wsDualHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" 
     binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService" 
     contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 
</configuration> 

爲什麼客戶端捕獲此異常?

編輯:

這裏就是我將消息發送到該服務是否有幫助C#代碼:

WCFServiceClient wcfObj; 
EndpointAddress ep = new EndpointAddress("http://localhost:8731/Design_Time_Addresses/WCF/WCFService/"); 
InstanceContext context = new InstanceContext(this); 
wcfObj = new Manager_WPF.WCFService.WCFServiceClient(context, "WSDualHttpBinding_IWCFService", ep); 
wcfObj.Subscribe(); 

wcfObj.messageHost(message); 
+0

會出現這種情況每次客戶端調用服務或後幾個郵件已發送(或當多個客戶端運行) –

+0

只有一個客戶端的時間連接的。每次我向服務發送消息時都會發生這種情況。 – Brian

+0

您可以在處理請求期間顯示合同並確定服務是否嘗試對客戶端進行回調? –

回答

1

我已經與Silverlight客戶端和雙工TCP綁定了同樣的問題。 probem是由從wcf方法調用返回之前調用客戶端的回調引起的。我已經把回調修正了這個調用到後臺線程:

... 
ThreadPool.QueueUserWorkItem(state => 
{     
    //this notifies service subscribers (calls registered callbacks)        
    OnConfigurationUpdated(EventArgs.Empty); 
}); 
return; 
相關問題