WCF 400 คำขอข้อมูลขนาดใหญ่ไม่ถูกต้อง

ฉันกำลังพัฒนาบริการ REST ใน .NET 4.0 และนี่คือไฟล์ web.config ของฉัน ซึ่งเป็นไฟล์ใหม่สำหรับ .NET และประสบปัญหามาสองวันแล้วเพื่อทำความเข้าใจว่าเหตุใดฉันจึงไม่สามารถอัปโหลดข้อมูลเกิน ~60KB ได้

ฉันเข้าใจโดย googling ว่าต้องเพิ่ม BufferSize และลองแก้ไขไฟล์ web.config ด้วยวิธีต่างๆ ที่ไม่เคยทำงาน ใครสามารถช่วยฉันได้บ้าง

ขอแสดงความนับถือ Hitesh

 <?xml version="1.0" encoding="utf-8"?>
 <configuration>   <system.web>
     <compilation debug="true" targetFramework="4.0">
       <assemblies>
         <add assembly="System.Data.Entity,
 Version=4.0.0.0, Culture=neutral,
 PublicKeyToken=b77a5c561934e089" />
       </assemblies>
     </compilation> <httpRuntime maxRequestLength="1048576"/>  
 </system.web>   <system.webServer>
     <modules runAllManagedModulesForAllRequests="true">
       <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0,
 Culture=neutral,
 PublicKeyToken=b03f5f7f11d50a3a" />
     </modules>   </system.webServer>   <system.serviceModel>
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
     <standardEndpoints>
       <webHttpEndpoint>
         <!-- 
             Configure the WCF REST service base address via the
 global.asax.cs file and the default
 endpoint 
             via the attributes on the <standardEndpoint> element below
         -->
         <standardEndpoint name="" helpEnabled="true"
 automaticFormatSelectionEnabled="true"
 />
       </webHttpEndpoint>
     </standardEndpoints> <services>

 <service name=""
 behaviorConfiguration="UpdateRealtimeWebPortfolioStructure.Service1Behavior"
 > <!-- Service Endpoints -->

 <endpoint address=""
 binding="wsHttpBinding"
 contract="UpdateRealtimeWebPortfolioStructure.IService1"
 bindingConfiguration="higherMessageSize_WS"><!--
 Upon deployment, the following
 identity element should be removed or
 replaced to reflect the

 identity under which the deployed
 service runs. If removed, WCF will
 infer an appropriate identity

 automatically.

 --> <identity>

 <dns value="localhost" /> </identity>

 </endpoint> <endpoint address="mex"
 binding="mexHttpBinding"
 contract="IMetadataExchange"
 bindingConfiguration="higherMessageSize_MEX"/>

 </service> </services>

 <bindings> <wsHttpBinding>

 <binding name="higherMessageSize_WS"
 closeTimeout="10:01:00"

 openTimeout="10:01:00"
 receiveTimeout="10:10:00"
 sendTimeout="10:01:00"

 bypassProxyOnLocal="false"
 transactionFlow="false"
 hostNameComparisonMode="StrongWildcard"

 maxBufferPoolSize="524288000"
 maxReceivedMessageSize="65536000"
 messageEncoding="Text"

 textEncoding="utf-8"
 useDefaultWebProxy="true"
 allowCookies="false"></binding>
 </wsHttpBinding>

 <mexHttpBinding> <binding
 name="higherMessageSize_MEX" />

 </mexHttpBinding>


 </bindings><behaviors>
 <serviceBehaviors>

 <behavior name=""> <!-- To avoid
 disclosing metadata information, set
 the value below to false and remove
 the metadata endpoint above before
 deployment -->

 <serviceMetadata httpGetEnabled="true"
 /> <dataContractSerializer
 maxItemsInObjectGraph="2147483647"/>

 <!-- To receive exception details in
 faults for debugging purposes, set the
 value below to true. Set to false
 before deployment to avoid disclosing
 exception information -->
 <serviceDebug
 includeExceptionDetailInFaults="false"
 />

 </behavior> </serviceBehaviors>

 </behaviors>   </system.serviceModel> 
 <connectionStrings>
     <add name="GeoContainer" connectionString="metadata=res://*/Geo.csdl|res://*/Geo.ssdl|res://*/Geo.msl;provider=System.Data.SqlClient;provider
 connection string=&quot;Data
 Source=YQLABSSERVER\SQLEXPRESS;Initial
 Catalog=Geo;Integrated
 Security=True;MultipleActiveResultSets=True&quot;"
 providerName="System.Data.EntityClient"
 />   
 </connectionStrings>
 </configuration>

person hiteshwar    schedule 04.09.2010    source แหล่งที่มา
comment
ฉันจัดรูปแบบ XML แล้ว แต่บางทีคุณสามารถลบทั้งหมดยกเว้นส่วนที่เกี่ยวข้องได้หรือไม่ และโพสต์อินเทอร์เฟซบางส่วน เรากำลังพูดถึง Streams, arrays ใหญ่, .... ?   -  person Henk Holterman    schedule 04.09.2010
comment
อาจซ้ำกันของ stackoverflow.com/questions/784606/   -  person Michael Freidgeim    schedule 13.09.2012


คำตอบ (2)


ฉันคิดว่าการเปลี่ยนแปลงการกำหนดค่าเดียวของ system.serviceModel ที่จำเป็นสำหรับการเพิ่มขนาดข้อความในสถานการณ์ REST โดยใช้ความเข้ากันได้ของ ASP.NET คือ:

<system.serviceModel>
  <bindings>
    <!-- default binding configration used for all REST services -->
    <webHttpBinding>
      <!-- max allowed message size incresed to 500 000 Bytes -->
      <binding maxBufferSize="500000" maxReceivedMessageSize="500000" />
    </webHttpBinding>
  </bindings>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
person Ladislav Mrnka    schedule 04.09.2010
comment
ฉันได้รับวิธีแก้ปัญหาโดยเพิ่มส่วนหัว maxBufferSize ให้กับแท็ก ‹serviceEndPoint› มันทำงานได้ดีตอนนี้ - person hiteshwar; 06.09.2010

ฉันได้รับวิธีแก้ปัญหาโดยเพิ่มส่วนหัว maxBufferSize ให้กับแท็ก <serviceEndPoint> มันทำงานได้ดีตอนนี้

person hiteshwar    schedule 06.09.2010