貌似这个问题已经被问过千百次了,但是每个人的配置问题都不一样。我有提供图像并接收上传图像请求的 WCF 服务器。上传图片时,当大小超过 65k 时出现错误 400。
我在 WCF 上打开了跟踪,我得到了确切的错误
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
我知道我需要增加这个参数,但我只能在我的 web.config 文件中找到它应该在哪里。这是我在 web.config 中的内容:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Streamed">
<readerQuotas maxDepth="128" 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>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ESLMobileIhaServiceClient.ServiceMobileIha" behaviorConfiguration="returnFaults">
<endpoint contract="ESLMobileIhaServiceClient.ServiceMobileIha" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex">
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
这里的任何人都可以帮助我解决这个问题吗?;) 尝试了 4 个小时,在 stackoverflow 上找到了不同的方法,但没有任何帮助 - 不幸的是。
更新:
该请求是从客户端到服务器的文件上传。启用诊断时,错误出现在服务器日志文件中。
服务器 Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Streamed">
<readerQuotas maxDepth="128" 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>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ESLMobileIhaServiceClient.ServiceMobileIha" behaviorConfiguration="returnFaults">
<endpoint contract="ESLMobileIhaServiceClient.ServiceMobileIha" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex">
</endpoint>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
客户端 App.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="InputFileLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\Stammdaten\"/>
<add key="OutputFileLocationOpen" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\offen\"/>
<add key="OutputFileLocationClosed" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\abgeschlossen\"/>
<add key="ImageObserveLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\kamerabilder\"/>
<add key="ImageSaveLocation" value="U:\vorlagen\esl_evu_demo\Mobile Instandhaltung\Testdaten\savedimages\"/>
<add key="DeleteImageAfterCopy" value="true"/>
<add key="HelpFile_de_DE" value="ESL_EVU_1031_Mobile_Instandhaltung.pdf"/>
<add key="HelpFile_fr_FR" value=""/>
<add key="BackupLocation" value="backup\"/>
<add key="NumOfBackups" value="3"/>
<add key="Language" value="de_DE"/>
<add key="FontType" value="Arial"/>
<add key="TextSize" value="10"/>
<add key="TitleTextSize" value="12"/>
<add key="ButtonTextSize" value="12"/>
<add key="IdentifikationGeraet" value="Kontrolle/Instandhaltung"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ServiceMobileIha" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01: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:51515/ServiceMobileIha.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ServiceMobileIha"
contract="ServiceReference1.ServiceMobileIha" name="BasicHttpBinding_ServiceMobileIha" />
</client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>