我正在开发一个可以上传和下载图片的网站。下载工作正常,没有问题,但同时上传有一个大于16 KB的图片的坏问题,告诉我:“协议异常:错误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)
听起来像是想要使用Streaming服务而不是Buffered的场景。
http://msdn.microsoft.com/en-us/library/ms733742.aspx
巧合的是,我正在努力实施自己。