2012-12-21 53 views
0

我正在开发一个可以上传和下载图片的网站。下载工作正常,没有问题,但与此同时上传有一个坏的问题,大于16 KB的图片,告诉我:“协议例外:错误400错误请求”。WCF:协议例外 - 400错误请求

这是告诉我,我必须增加XmlDictionaryReaderQuotas中MaxArrayLength的大小,但我已经这样做了。

我会告诉你我的webConfig:

客户:

<bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IServiceImage" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="4194304" maxBufferPoolSize="4194304" maxReceivedMessageSize="4194304" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="4194304" maxStringContentLength="4194304" maxArrayLength="4194304" 
      maxBytesPerRead="4194304" maxNameTableCharCount="4194304" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

WCF:

<bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IServiceImage" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="4194304" maxReceivedMessageSize="4194304" 
     messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
     allowCookies="false"> 
      <readerQuotas maxDepth="4194304" maxStringContentLength="4194304" maxArrayLength="4194304" 
      maxBytesPerRead="4194304" maxNameTableCharCount="4194304" /> 
      <security mode="Message"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

任何想法?

编辑:我可以上传文件,直到它们小于16KB,并且我无法找到必须处理该值才能增加的位置。


听起来像是巨大的文件,WCF已经得到了一些问题,所以我要改变“encodeMessage”以MTOM和BasicHttpBindings移到wsHttpBindings。顺便说一下,这还没有工作,新的问题出现在我的代码。该死的。

客户WebConfig:

<bindings> 

    <wsHttpBinding> 
    <binding name="wsHttpBinding_IService1" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="4194304" maxReceivedMessageSize="4194304" 
     messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true" 
     allowCookies="false"> 
     <readerQuotas maxDepth="4194304" maxStringContentLength="4194304" 
     maxArrayLength="4194304" maxBytesPerRead="4194304" maxNameTableCharCount="4194304" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

服务WebConfig:

<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpBinding_IService1" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 

      maxBufferPoolSize="4194304" maxReceivedMessageSize="4194304" 
     messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"> 
     <!--messageEncoding="Text" textEncoding="utf-8" maxBufferSize="4194304" transferMode="Buffered" --> 
     <readerQuotas maxDepth="4194304" maxStringContentLength="4194304" 
     maxArrayLength="4194304" maxBytesPerRead="4194304" maxNameTableCharCount="4194304" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 


<services> 
    <service name="WcfService.FileService" > 
    <endpoint address="" binding="wsHttpBinding" contract="WcfService.IService1" /> 
    </service> 
</services> 
+0

您的配置是否用于服务端点? –

+0

@LadislavMrnka:我认为这是你在问: <端点地址= “HTTP://本地主机:XXXXX/Service1.svc” 绑定= “basicHttpBinding的” bindingConfiguration = “BasicHttpBinding_IServiceImage” 合同=“WCFImages .IServiceImage“ name =”BasicHttpBinding_IServiceImage“/> 就像我说的,对于小图像,工作正常。大于2KB不是。 – Fenuska

+0

web.config中'maxRequestLength'的价值是什么? – dmusial

回答