WCF:远程服务器返回错误:(413)请求实体太大 [英] WCF: The remote server returned an error: (413) Request Entity Too Large

查看:55
本文介绍了WCF:远程服务器返回错误:(413)请求实体太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有wcf服务

有一种方法可以获取base64字符串来上传文件,而我的文件大小为100kb,时间可能会更大

我收到错误消息:远程服务器返回错误:(413)请求实体太大同时尝试获取HttpWebResponse

这是我的wcf服务web.config

 < system.serviceModel>< bindings>< webHttpBinding>< binding name =" webHttpTransportSecurity" ;;allowCookies ="false"maxReceivedMessageSize ="104857600"< readerQuotas maxDepth =" 2147483647"maxStringContentLength ="2147483647";maxArrayLength ="2147483647";maxBytesPerRead ="2147483647";/><安全模式=运输">< transport clientCredentialType ="None"/></security></binding></webHttpBinding></bindings><服务><服务名="FHServices.FHSmartService";behaviorConfiguration ="ServiceBehaviour"<端点地址="binding ="webHttpBinding"contract ="FieldHoundServices.IFHSmartService";behaviorConfiguration ="web"></endpoint><主机>< baseAddresses>< add baseAddress =" http://localhost/FHServices/FHSmartService.svc/"/></baseAddresses></host></service></services><行为>< serviceBehaviors><行为名称="ServiceBehaviour">< serviceMetadata httpGetEnabled ="true";httpsGetEnabled ="true"/>< serviceDebug includeExceptionDetailInFaults ="true";/></行为></serviceBehaviors>< endpointBehaviors><行为名称=网络">< webHttp/></行为></endpointBehaviors></行为>< serviceHostingEnvironment aspNetCompatibilityEnabled ="true";multipleSiteBindingsEnabled ="true";/></system.serviceModel> 

我的错误是什么?


已解决

我发现了我的错误我删除了这些代码

 <安全模式=运输">< transport clientCredentialType ="None"/></security> 

我认为https的传输模式,并且没有ssl,因此我们不需要传输模式.无论如何,在我删除它之后,一切似乎都可以了

解决方案

您没有为端点分配已定义的 WebHttpBinding 配置,因此端点将使用默认值进行绑定.

您可以通过在< endpoint> 元素上的 bindingConfiguration 属性中指定端点来告知端点使用绑定配置,如下所示:

 <端点地址=" binding ="webHttpBinding"bindingConfiguration ="webHttpTransportSecurity"contract ="FieldHoundServices.IFHSmartService"behaviorConfiguration ="web"></endpoint> 

I have a wcf service

there is a method which gets base64 string to upload a file my file's size 100kb it may be larger in time

i got the error message: The remote server returned an error: (413) Request Entity Too Large while try to get HttpWebResponse

this is my wcf service web.config

<system.serviceModel>
<bindings>
  
  <webHttpBinding>
    
    <binding name="webHttpTransportSecurity" allowCookies="false" maxReceivedMessageSize="104857600">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
       maxBytesPerRead="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service name="FHServices.FHSmartService" behaviorConfiguration="ServiceBehaviour">
    
    <endpoint address="" binding="webHttpBinding" contract="FieldHoundServices.IFHSmartService" behaviorConfiguration="web">
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/FHServices/FHSmartService.svc/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>
  </endpointBehaviors>
</behaviors>
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

what is my mistake?


solved

i found my mistake i remove these codes

<security mode="Transport">
    <transport clientCredentialType="None" />
  </security>

i think transport mode for https and we have no ssl so we dont need transport mode. anyway after i remove it, everything seems ok now

解决方案

You don't assign a defined WebHttpBinding configuration to your endpoint, so the endpoint uses the default values for the binding.

You can tell the endpoint to use your binding congfiguration by specifying it in the bindingConfiguration attribute on the <endpoint> element, like this:

<endpoint address="" binding="webHttpBinding"
          bindingConfiguration="webHttpTransportSecurity"
          contract="FieldHoundServices.IFHSmartService" 
          behaviorConfiguration="web">
</endpoint>

这篇关于WCF:远程服务器返回错误:(413)请求实体太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆