gpt4 book ai didi

wcf - 远程服务器返回意外响应 : (400) Bad Request

转载 作者:行者123 更新时间:2023-12-01 00:05:20 24 4
gpt4 key购买 nike

调用我的 WCF 服务方法时没有错误,除了一个。

这个称为 SaveTemplate() 的特殊方法接受 byte[] 的输入。

我正在使用大小为字节 [806803] 的文件测试此方法,
但以错误结尾:

WCF - The remote server returned an unexpected response: (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>

最佳答案

由于您似乎是在 IIS 中的 ASP.NET 内部托管,因此除了 WCF 的各种设置之外,您还需要确保还设置了 ASP.NET 允许的请求长度。对于 ASP.NET,您要查找的设置是 maxRequestLengththe httpRuntime element .此设置的默认值仅为 4MB,因此这可以解释您遇到问题的原因。

对于 512MB 的 maxLength,这看起来有点像这样:

<system.web>
<httpRuntime maxRequestLength="524288" />

<!-- rest of your config here -->
</system.web>

关于wcf - 远程服务器返回意外响应 : (400) Bad Request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1651143/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com