2010-05-25 70 views
7

我的WCF服务有一个OperationContract,它接受一个对象数组作为参数。这可能会相当大。在查找Bad Request:400的修复程序后,我找到了真正的原因:最大的消息大小。传入邮件的最大邮件大小限额(65536)已被超出

我知道这个问题已经在很多地方被问过。我试过每个人都说:“增加客户端和服务器配置文件的大小。”我有。它仍然不起作用。

我服务的web.config:

<system.serviceModel> 
    <services> 
     <service name="myService"> 
     <endpoint name="myEndpoint" address="" 
        binding="basicHttpBinding" 
        bindingConfiguration="myBinding" 
        contract="Meisel.WCF.PDFDocs.IPDFDocsService" /> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="myBinding" 
       closeTimeout="00:11:00" 
       openTimeout="00:11:00" 
       receiveTimeout="00:15:00" 
       sendTimeout="00:15:00" 
       maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       maxBufferPoolSize="2147483647" 
       transferMode="Buffered" 
       allowCookies="false" 
       bypassProxyOnLocal="false" 
       hostNameComparisonMode="StrongWildcard" 
       messageEncoding="Text" 
       textEncoding="utf-8" 
       useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" 
         maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647" /> 
      <security mode="None" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

我的客户的app.config:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IPDFDocsService" 
       closeTimeout="00:11:00" 
       openTimeout="00:11:00" 
       receiveTimeout="00:10:00" 
       sendTimeout="00:11:00" 
       allowCookies="false" 
       bypassProxyOnLocal="false" 
       hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" 
       maxBufferPoolSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" 
       textEncoding="utf-8" 
       transferMode="Buffered" 
       useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" 
         maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" 
         proxyCredentialType="None" 
         realm="" /> 
      <message clientCredentialType="UserName" 
        algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8451/PDFDocsService.svc" 
       behaviorConfiguration="MoreItemsInObjectGraph" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_IPDFDocsService" 
       contract="PDFDocsService.IPDFDocsService" 
       name="BasicHttpBinding_IPDFDocsService" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="MoreItemsInObjectGraph"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

我能可能被丢失或做错了什么?就好像该服务忽略了我在maxReceivedBufferSize中输入的内容。

由于提前, 凯尔

UPDATE

这里是他们从来没有收到答复其他两个StackOverflow的问题,无论是:

https://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with

WCF MaxReceivedMessageSize property not taking

+0

它看起来正确一目了然。你是否在代码中配置了终点?如果是这样,那可能会覆盖配置设置。 – 2010-05-25 22:07:42

+0

你是如何托管这项服务的? IIS? – 2010-05-25 23:58:27

+0

@Jeff:我刚刚创建了一个新的服务客户端实例,然后调用OperationContract,传入我的自定义类作为参数。没有什么花哨。 @Simon:我正在使用ASP .NET开发服务器。目前,它都是本地的。 – DaleyKD 2010-05-26 00:45:58

回答

7

在里面服务配置文件,“名称”属性中,通过元素

<behaviors> 
    <serviceBehaviors> 
    <behavior name="StackOverflow"> 

失踪,应该在服务元素添加到此名称的引用:

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="StackOverflow" name="myService"> 
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding" 

一般情况下,这是个好主意使用从Visual Studio“工具”菜单项调用的“WCF服务配置编辑器”验证(如果不是始终编辑)您的WCF配置文件。

此外,没有为该服务定义端点行为。我不知道这是否重要。

+0

如果我告诉你,当我为我的行为添加一个名称时,WCFTestClient会给我错误信息:“错误:无法获取元数据。元数据包含无法解析的引用。 charset = utf-8不被服务支持,客户端和服务绑定可能不匹配,远程服务器返回一个错误:(415)Unsupported Media Type.HTTP GET .HTML文档不包含Web服务发现信息。这就是为什么我没有为自己的行为列入名字的原因。 – DaleyKD 2010-05-26 15:11:35

+0

我仍然不确定这个问题真正的解决方案是什么,但是我能够解决我的ORIGINAL问题,使这个问题没有实际意义。 FWIW,看起来好像我能够通过使SURE服务使用behaviorConfiguration来摆脱上述错误。谢谢! – DaleyKD 2010-05-26 19:53:51

0

我有与WCF测试相同的问题,我正确地设置了配置文件。如果你的配置文件没有任何问题,我建议尝试用另一个程序来测试服务,例如:SOAP UI,我认为这个错误不是来自服务,而是来自WCF Test。

相关问题