 |
|
บันทึกรูปใน sql server โดยผ่าน WCF Service ไม่ได้ C# - the remote server returned an unexpected response (413) request entity too large |
|
 |
|
|
 |
 |
|
คือมัน error แบบนี้ครับ
Error
the remote server returned an unexpected response (413) request entity too large

มันบอกว่า file ใหญ่เกีนไป แต่รูบมีแค่ 55.5 KB เองครับ
หาวิธีแก้ในเน็ด 2 วันแล้ว ทำตามเขาก็ไม่ได้ เขาบอกไปแก้ที่ Web.config แก้ตามเขา แต่ก็ไม่ได้ ช่วยแนะนำด้วยครับ
file Web.config อยู่ฝั่ง Service
Code (XML)
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="d:\sharesourcehospital\hospital4\hospitalserver\web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<connectionStrings>
<add name="sqlconnect"
connectionString="Data Source=GM-VATH\SQLEXPRESS;Initial Catalog=Hospital;User ID=sa;Password=12345"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxRequestLength="2097151000" targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- 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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<!-- custom insert -->
<bindings>
<basicHttpBinding>
<binding name="wsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8"
transferMode="Streamed">
<!--<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />-->
<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>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
App.config ฝั่ง Client ครับ
Code (XML)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="d:\sharesourcehospital\hospital4\hospital\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<connectionStrings>
<add name="sqlconnect"
connectionString="Data Source=GM-VATH\SQLEXPRESS;Initial Catalog=Hospital;User ID=sa;Password=12345"
providerName="System.Data.SqlClient" />
</connectionStrings>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime sku=".NETFramework,Version=v4.0" version="v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IHospitalService" closeTimeout="00:11:00"
openTimeout="00:11:00" receiveTimeout="00:11:00" sendTimeout="00:11:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
<binding name="BasicHttpBinding_IHospitalService1" closeTimeout="00:11:00"
openTimeout="00:11:00" receiveTimeout="00:11:00" sendTimeout="00:11:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
<binding name="BasicHttpBinding_IService1" closeTimeout="00:11:00"
openTimeout="00:11:00" sendTimeout="00:11:00" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
<binding name="BasicHttpBinding_IService11" closeTimeout="00:11:00"
openTimeout="00:11:00" sendTimeout="00:11:00" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<!--http://localhost:9682/HospitalService.svc -->
<endpoint address="http://localhost:9682/HospitalService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHospitalService"
contract="HosService.IHospitalService" name="BasicHttpBinding_IHospitalService" />
<endpoint address="http://localhost:9682/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ActionService1.IService1"
name="BasicHttpBinding_IService1" />
<endpoint address="http://localhost:9682/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService11" contract="ActionService.IService1"
name="BasicHttpBinding_IService11" />
</client>
</system.serviceModel>
</configuration>
Tag : .NET, Ms SQL Server 2012, C#
|
|
 |
 |
 |
 |
Date :
2015-03-31 14:01:55 |
By :
hacker2015 |
View :
2098 |
Reply :
10 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าไฟล์เล็ก ๆ ได้หรือเปล่าครับ เช่นซะ 2-4 K ประมาณนี้ครับ ถ้าได้แสดงว่าน่าจะต้องไปหา Config พวก Size อะไรซะอย่างที่เกี่ยวข้องครับ
|
 |
 |
 |
 |
Date :
2015-04-01 07:39:35 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ที่แนะนำ ผมแก้ตามแล้ว แต่ยังไม่ได้ เดี๋ยวผมจะค้นหาต่อไป หวังว่าสักวันมันต้องได้ 
|
 |
 |
 |
 |
Date :
2015-04-01 14:12:16 |
By :
hacker2015 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดูครับ ถ้าได้ยังไงรบกวนกลับมาบอกวิธีด้วยครับ 
|
 |
 |
 |
 |
Date :
2015-04-02 09:41:12 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ
5 วันเต็มๆ
ถ้าใคร Error แบบเดียวกันกับผมก็ลองเอาไปปรับดูครับ
SERVICE SIDE
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Service.AdMapServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Service.AdMapServiceBehavior"
name="Service.AdMapService">
<endpoint address="" binding="wsHttpBinding" contract="Service.IAdMapService" name="wsHttp" bindingConfiguration="wsHttpBindingConfiguration">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration" maxReceivedMessageSize="65536000" messageEncoding="Text" maxBufferPoolSize="65536000">
<readerQuotas maxArrayLength="65536000" maxBytesPerRead="65536000" maxDepth="65536000" maxStringContentLength="2048576" maxNameTableCharCount="2048576" ></readerQuotas>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
CLIENT SIDE
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="65536000" maxReceivedMessageSize="65536000" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="65536000" maxStringContentLength="65536000" maxArrayLength="65536000"
maxBytesPerRead="65536000" maxNameTableCharCount="65536000" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false"/>
<!--<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>-->
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:7352/AdMapService.svc" binding="wsHttpBinding"
contract="AdMapServiceReference.IAdMapService"
name="wsHttp" behaviorConfiguration="WSHttpBinding_IAdMapService" bindingConfiguration="wsHttpBindingConfiguration">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="WSHttpBinding_IAdMapService">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
|
ประวัติการแก้ไข 2015-04-03 11:49:18
 |
 |
 |
 |
Date :
2015-04-03 11:47:48 |
By :
keooudone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประเด็นหลักมันอยู่ที่ Set ค่าอะไรครับ
|
 |
 |
 |
 |
Date :
2015-04-03 11:56:36 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่แน่ใจครับ
เพาะแก้จาก code เดีมผมหลายแถวมาก ผม copy ของเขา มาทับของเดีม แล้วเปลี่ยน endpoint ให้ใช้งานกับ WCF Service ผม  
|
 |
 |
 |
 |
Date :
2015-04-03 13:28:57 |
By :
keooudone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2015-04-03 13:40:49 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|