2011-01-27 78 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

如果可能并且客户端可以接受,则可以将文件分解为更小如果您没有数字证书等,并在客户端进行排序,您可以发送大量数据并传送。