2011-01-27 80 views
0

我已經查看了許多類似的主題,但沒有找到幫助解決這個問題的方法。帶有大參數的WCF服務

有一個接受XML處理的WCF服務。我正在閱讀的XML文件是〜600K。

呼叫適用於小型的XML文件(大部分時間),但在較大的文件,我得到的錯誤:

System.ServiceModel.Security.MessageSecurityException:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

其中內部的例外是:

System.ServiceModel.FaultException:
The message could not be processed. This is most likely because the action 'http://tempuri.org/ISapListener/ProcessSapRoles' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

就像我說...它適用於小文件,並且我的打開,發送,接收,關閉和非活動超時都設置爲10分鐘。它在大約20-30秒內失敗。

此外,服務器和客戶端的時鐘完全同步(我已經看到,發佈爲答案)。

我的配置文件,因爲它們目前站(我打了很多的設置):

服務器:

<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpBinding_Custom" closeTimeout="00:00:10" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" 
      sendTimeout="00:10:00" bypassProxyOnLocal="false" 
      transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
      messageEncoding="Text" textEncoding="utf-8" 
      useDefaultWebProxy="true" allowCookies="false" 
      maxReceivedMessageSize="1024768"    
      maxBufferPoolSize="1024768" > 
     <readerQuotas maxDepth="32" maxBytesPerRead="4096" 
        maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
        realm="" /> 
     <message clientCredentialType="Windows" 
       negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="CSA.GS3.Services.SapListenerBehavior" 
      name="CSA.GS3.Services.SapListener"> 
    <endpoint address="" binding="wsHttpBinding" 
       bindingConfiguration="wsHttpBinding_Custom" 
       contract="CSA.GS3.Services.ISapListener"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" 
       contract="IMetadataExchange" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="CSA.GS3.Services.SapListenerBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

客戶:

<bindings> 
    <wsHttpBinding> 
    <binding name="WSHttpBinding_ISapListener1" 
      closeTimeout="00:10:00" openTimeout="00:10:00" 
      receiveTimeout="00:10:00" sendTimeout="00:10:00" 
      bypassProxyOnLocal="false" transactionFlow="false" 
      hostNameComparisonMode="StrongWildcard" 
      messageEncoding="Text" textEncoding="utf-8" 
      useDefaultWebProxy="true" allowCookies="false" 
      maxBufferPoolSize="1024768" 
      maxReceivedMessageSize="1024768"> 
     <readerQuotas maxDepth="32" maxBytesPerRead="4096" 
        maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="Windows" 
       negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint address="http://gs3-test.us.tycoelectronics.com/SapListener/SapListener.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISapListener1" 
      contract="Gs3TestSapListener.ISapListener" 
      name="WSHttpBinding_ISapListener1"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
    </endpoint> 
</client> 

做的都啓用跟蹤我在服務上,但我無法理解日誌文件。

而與配置設置打我收到

其他異常:

System.ServiceModel.Security.SecurityNegotiationException
Secure channel cannot be opened because security negotiation with the remote endpoint has failed.

System.ServiceModel.ServiceActivationException
The requested service, 'http://../SapListener.svc' could not be activated.

+0

它是否總是失敗的大文件? – 2011-01-27 20:11:40

+0

是的......小的人通常工作,雖然我偶爾會遇到一些問題,但通常要麼重新啓動服務,要麼重新嘗試修復它 – 2011-01-27 20:16:10

+0

順便說一句,有一種情況,它在本地工作,但不是針對遠程客戶?那是你有一個測試客戶端在本地運行,併發送大內容,它不會失敗? – 2011-01-27 20:36:02

回答

0

我能得到這個具有以下配置工作:

服務器:

<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpBinding_Custom" 
      closeTimeout="00:10:00" 
      openTimeout="00:10:00" 
      receiveTimeout="00:10:00" 
      sendTimeout="00:10:00" 
      maxReceivedMessageSize="2097152" 
      bypassProxyOnLocal="false" transactionFlow="false" 
      hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="2097152" messageEncoding="Text" 
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
     <readerQuotas maxDepth="32" maxBytesPerRead="4096" 
        maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
        realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

客戶:

<bindings> 
    <wsHttpBinding> 
    <binding name="WSHttpBinding_ISapListener1" closeTimeout="00:10:00" 
      openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
      bypassProxyOnLocal="false" transactionFlow="false" 
      hostNameComparisonMode="StrongWildcard" 
      maxBufferPoolSize="2097152" 
      maxReceivedMessageSize="2097152" 
      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
      allowCookies="false"> 
     <readerQuotas maxDepth="32" maxBytesPerRead="4096" 
        maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
        realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

我能看到的唯一區別是,我碰上了maxReceivedMessageSize和maxBufferPoolSize ...也許我錯過了別的東西?如果這是問題,那麼問題是我的通話費用是在我發送的600K xml數據中增加一個額外的400 + K

0
System.ServiceModel.ServiceActivationException 
The requested service, 'http://../SapListener.svc' could not be activated. 

這可能是編譯錯誤或無效配置。

它是WCF 4.0嗎?然後,您可以刪除自定義配置並使用自動綁定。我還建議你嘗試綁定,而不是像wsHttpBinding,就像basicHttpBinding。

0

如果可能並且客戶端可以接受,則可以將文件分解爲更小如果您沒有數字證書等,並在客戶端進行排序,您可以發送大量數據並傳送。