我正在尝试使用WCF服务,但是却收到HTTP 413错误“请求实体太大”。
我使用以下配置WCF服务的web.config:
<system.serviceModel>
<services>
<service name="MyCompany.WCF.Payments.SWPayments" behaviorConfiguration="behaviorPayments">
<endpoint binding="basicHttpBinding" contract="MyCompany.WCF.Payments.Contract.ISWPayments" address="">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorPayments">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Payments" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<client>
<endpoint address="http://server:port/MyCompanyWCFPayments/Payments.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Payments" contract="MyCompany.WCF.Payments.Contract.ISWPayments" name="BasicHttpBinding_Payments" />
</client>
</system.serviceModel>
如您所见,属性的值设置为最高值。但是我收到HTTP 413错误。
我想念什么吗?
提前致以最诚挚的问候。期待您在上面发表评论。
答案 0 :(得分:0)
服务器和客户端似乎在同一台计算机上。我们至少应确保将绑定配置应用于服务器。此外,请不要忘记使用BindingConfiguration属性将该配置应用于服务器的绑定配置。
<services>
<service name="MyCompany.WCF.Payments.SWPayments" behaviorConfiguration="behaviorPayments">
<endpoint bindingConfiguration="BasicHttpBinding_Payments" binding="basicHttpBinding" contract="MyCompany.WCF.Payments.Contract.ISWPayments" address="">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
请随时让我知道问题是否仍然存在。