WCF错误400错误请求

时间:2013-02-05 04:53:03

标签: asp.net wcf streaming

我正在尝试将数据文件上传到WCF服务,它可以正常使用小文件。但是,当我尝试上传大小为2MB的文件时,我收到错误400 Bad Request。

由于它适用于小文件,我不得不认为最大尺寸限制存在问题,但我已将它们全部增加,但仍然会出现同样的错误。

感谢您帮助我指导正确的方向。谢谢:))

我在WCF服务中使用以下配置。

这是服务配置

 <!-- WIZARD FILE UPLOAD CONFIGURATION -->
  <service behaviorConfiguration="BBS.eBillity.Services.ServiceBehavior" name="BBS.eBillity.Services.Modules.IWizardUploadFile">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="WizardUploadFile_StreamedBinding"
     contract="BBS.eBillity.Services.Contracts.ServicesContracts.IWizardUploadFile">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
  </service>

服务的绑定配置

<binding name="WizardUploadFile_StreamedBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
             transferMode="StreamedRequest" closeTimeout="04:01:00"
 openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="2147483647"   useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
           maxArrayLength="2147483647" maxBytesPerRead="2147483647"
           maxNameTableCharCount="2147483647"/>
    </binding>

服务合同,非常简单......

[ServiceContract]
public interface IWizardUploadFile
{

    [OperationContract]
    void UploadFiletoServer(Stream request);

}

在system.web标记内,我在客户端和服务器配置文件中添加了以下内容

<httpRuntime maxRequestLength="2147483647" />

这是客户端配置:

 <basicHttpBinding>

 <binding name="BasicHttpBinding_IWizardUploadFile" closeTimeout="04:01:00"
 openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
 allowCookies="false" bypassProxyOnLocal="false"
 hostNameComparisonMode="StrongWildcard"
 maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
 maxReceivedMessageSize="2147483647"
      transferMode="Streamed"
 useDefaultWebProxy="true">
   <readerQuotas maxDepth="2147483647"
       maxStringContentLength="2147483647" maxArrayLength="2147483647"
       maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
   <security mode="None">
     <transport clientCredentialType="None"
             proxyCredentialType="None" realm="" />
     <message clientCredentialType="UserName" algorithmSuite="Default" />
   </security>
 </binding>

端点配置

<endpoint address="http://localhost:1234/WCFeBillity/WizardUploadFile.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWizardUploadFile"
contract="WizardUploadFile.IWizardUploadFile" name="BasicHttpBinding_IWizardUploadFile" />

0 个答案:

没有答案