在调用我的WCF服务方法时,我没有收到任何错误。
这个名为SaveTemplate()的特殊方法接受byte []的输入。
我正在使用大小为byte [806803]的文件测试此方法, 但以错误结束:
WCF - 远程服务器返回了意外响应:(400)Bad Request。*
我已经查看了我在Google上找到的几个搜索结果并根据这些更改了app.config,但仍然收到错误: - (
这是我的WCF服务库的App.Config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttp" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000"
messageEncoding="Mtom" >
<readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000"
maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
name="ReportingComponentLibrary.TemplateService">
<endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateService" bindingConfiguration="wsHttp" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateService/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
name="ReportingComponentLibrary.TemplateReportService">
<endpoint address="" binding="wsHttpBinding" contract="ReportingComponentLibrary.ITemplateReportService" bindingConfiguration="wsHttp" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ReportingComponentLibrary/TemplateReportService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ReportingComponentLibrary.TemplateServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
答案 0 :(得分:5)
由于您似乎在IIS中的ASP.NET内部托管,因此除了WCF的各种设置之外,还需要确保ASP.NET允许的请求长度。对于ASP.NET,您要查找的设置是the httpRuntime
element maxRequestLength
。此设置的默认值仅为4MB,因此可以解释您遇到问题的原因。
对于512MB maxLength来说,这看起来有点像这样:
<system.web>
<httpRuntime maxRequestLength="524288" />
<!-- rest of your config here -->
</system.web>
答案 1 :(得分:0)
感谢您的帮助!
这是我的无知导致我花了这么多时间来解决它。
我无法使用新的Binding配置更新Windows服务的配置文件。相反,我只是在Windows服务目录中复制一个单独的配置文件。
答案 2 :(得分:0)
我的50美分:将httpRuntime元素的maxRequestLength属性值从65536更改为2147483647。