【问题标题】:Request entity too large wcf iis8请求实体太大 wcf iis8
【发布时间】:2014-05-14 14:26:31
【问题描述】:

我的 wcf 服务有问题。 我已阅读有关此错误的所有帖子,我尝试了几乎所有的道具,但它不起作用! 我想上传小于 1 mb 的图片。

我的客户端通过代码配置: EndpointAddress ea = new EndpointAddress("AddressofServer"); BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); XmlDictionaryReaderQuotas reader = new XmlDictionaryReaderQuotas(); basicHttpBinding.MaxBufferSize = 2147483647; basicHttpBinding.MaxBufferPoolSize = 2147483647; basicHttpBinding.MaxReceivedMessageSize = 2147483647; reader.MaxStringContentLength = 2147483647; reader.MaxDepth = 2147483647; reader.MaxArrayLength = 2147483647; reader.MaxBytesPerRead = 2147483647; reader.MaxNameTableCharCount = 2147483647; basicHttpBinding.ReaderQuotas = 读者;

        basicHttpBinding.SendTimeout = new TimeSpan(0, 0, 50);
        basicHttpBinding.OpenTimeout = new TimeSpan(0, 0, 5);
        basicHttpBinding.ReceiveTimeout = basicHttpBinding.SendTimeout;
        basicHttpBinding.AllowCookies = false;
        basicHttpBinding.Security.Mode = BasicHttpSecurityMode.None;

        ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client(basicHttpBinding, ea);


        string nm = sc.Endpoint.Binding.Name;
        using (FileStream fs = new FileStream("c:\\httpfiles\\test.jpg", FileMode.Open))
        {
            byte[] buffer = new byte[fs.Length];
            fs.Read(buffer, 0, buffer.Length);
            sc.GetImage(1, "appareillage", buffer);
        }

我的 web.config 文件:

   <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="bnd"
 maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
 maxBufferSize="2147483647"    closeTimeout="00:10:00" openTimeout="00:10:00"
 receiveTimeout="00:10:00" sendTimeout="00:10:00" messageEncoding="Text">
      <readerQuotas
        maxArrayLength="2147483647"
        maxStringContentLength="2147483647" />
      <security mode="None"/>
    </binding>
  </basicHttpBinding>
</bindings>
<serviceHostingEnvironment
  multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
<services>
  <service name="PodoTouchService.PTouchService" behaviorConfiguration="" >
    <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="bnd"
        contract="Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
</system.serviceModel>
<system.webServer>
<security>
  <requestFiltering allowDoubleEscaping="true">
    <requestLimits maxAllowedContentLength="2147483647"/>
    <fileExtensions allowUnlisted="true"/>
    <verbs allowUnlisted="true"/>
  </requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>

我也尝试更改 applicationHost.config。

有什么想法吗?

【问题讨论】:

  • 错误是什么?复制并粘贴异常。

标签: wcf iis-8


【解决方案1】:

感谢回复,我找到了问题。 创建服务后,我将 ServiceContract 属性更改为

[ServiceContract(Namespace="PTouchService")]
public interface IService1

 And in the web config file i could not matched this name space. And as a result all changes that i tried did not work. 

这是我的网络配置文件的工作版本:

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PTouchService.Service1Behavior">
      <!-- Pour éviter la divulgation d'informations de métadonnées, définissez la valeur ci-dessous sur false avant le déploiement -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- Pour recevoir les détails de l'exception dans les erreurs à des fins de débogage, définissez la valeur ci-dessous sur true. Pour éviter la divulgation d'informations d'exception, définissez-la sur false avant le déploiement -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="bnd" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
      <security mode="None"/>
    </binding>
  </basicHttpBinding>
</bindings>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-17
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 2020-02-05
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多