У меня возникли проблемы с настройкой свойства maxRecievedMessageSite
для basicHttpBinding
. Я хочу создать конечную точку для загрузки потенциально больших файлов, однако текущее (я полагаю, по умолчанию) ограничение составляет 64 КБ. Для таких элементов, как изображения и большие документы, это ограничение просто не будет работать. Я создал новую привязку из basicHttpBinding
, но продолжаю получать ошибки в трассировке стека, сообщая мне, что я превысил предел. Ниже я включил соответствующие части из моего файла конфигурации, файла Global.asax, моего операционного контракта и моей реализации сервиса. (все очень просто, просто пытаюсь заставить его работать).
Файл конфигурации
<system.webServer>
<system.serviceModel>
<services>
<!-- CarImage Service Configuration -->
<service name="CarImageService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="FileTransferServicesBinding"
contract="ICarImageService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<!-- buffer: 64KB; max size: 64MB -->
<binding name="FileTransferServicesBinding"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:01:00"
sendTimeout="00:01:00"
transferMode="Streamed"
messageEncoding="Mtom"
maxBufferSize="999999"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="99999">
<security mode="None" >
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
Файл Global.asax
namespace Mavizon.Mavia.Services
{
public class Global : HttpApplication
{
private string FilePath = ConfigurationManager.AppSettings["ImageFolder"];
void Application_Start(object sender, EventArgs e)
{
if (!Directory.Exists(FilePath))
{
Directory.CreateDirectory(FilePath);
}
RegisterRoutes();
}
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("test", new WebServiceHostFactory(), typeof(CarImageService)));
}
}
}
Операционный договор
namespace Mavizon.Mavia.Services.OperationContracts
{
[ServiceContract]
public interface ICarImageService
{
[OperationContract]
[FaultContract(typeof(ErrorFault))]
[WebInvoke(Method = "POST", UriTemplate = "/")]
void UploadImage(Stream request);
}
}
Мой (очень) простой класс реализации
namespace Mavizon.Mavia.Services.WebServices
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class CarImageService : OperationContracts.ICarImageService
{
public void UploadImage(Stream request)
{
}
}
}
** Вот моя информация трассировки стека **
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
<StackTrace>
at System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception&amp; requestException)
at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(ContextCallback callback, Object state)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.ServiceModel.ProtocolException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.</ExceptionString><DataItems><Data><Key>System.ServiceModel.Channels.HttpInput.HttpStatusCode</Key><Value>BadRequest</Value></Data></DataItems></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:56:04.3623047Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{c05370d6-4c2f-4320-882f-365bf055e88f}" RelatedActivityID="{1782abf6-9c78-487d-91b0-29586d6140ad}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:56:04.3623047Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{c05370d6-4c2f-4320-882f-365bf055e88f}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Stop"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>f5dae6e-2-129526377562529297</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Processing message 1.</ActivityName><ActivityType>ProcessMessage</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Resume">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:56:04.3623047Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{1782abf6-9c78-487d-91b0-29586d6140ad}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Resume"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>f5dae6e-2-129526377562529297</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Listen at 'http://localhost:2947/test'.</ActivityName><ActivityType>ListenAt</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" RelatedActivityID="{a7f8d8f5-ff82-4283-9ea2-4eb8a55a51a5}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Start">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a7f8d8f5-ff82-4283-9ea2-4eb8a55a51a5}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Start"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>f5dae6e-2-129526377562529297</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Close ServiceHost 'Mavizon.Mavia.Services.WebServices.CarImageService'.</ActivityName><ActivityType>Close</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a7f8d8f5-ff82-4283-9ea2-4eb8a55a51a5}" RelatedActivityID="{00000000-0000-0000-0000-000000000000}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a7f8d8f5-ff82-4283-9ea2-4eb8a55a51a5}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Stop"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>f5dae6e-2-129526377562529297</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Close ServiceHost 'Mavizon.Mavia.Services.WebServices.CarImageService'.</ActivityName><ActivityType>Close</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{a7f8d8f5-ff82-4283-9ea2-4eb8a55a51a5}" RelatedActivityID="{1782abf6-9c78-487d-91b0-29586d6140ad}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Transfer">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{1782abf6-9c78-487d-91b0-29586d6140ad}" RelatedActivityID="{a7f8d8f5-ff82-4283-9ea2-4eb8a55a51a5}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData></ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>131085</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2011-06-15T18:59:36.5878906Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{1782abf6-9c78-487d-91b0-29586d6140ad}" /><Execution ProcessName="WebDev.WebServer40" ProcessID="2268" ThreadID="5" /><Channel/><Computer>JOHNMURRAY027D</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Stop"><TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ActivityBoundary.aspx</TraceIdentifier><Description>Activity boundary.</Description><AppDomain>f5dae6e-2-129526377562529297</AppDomain><ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"><ActivityName>Listen at 'http://localhost:2947/test'.</ActivityName><ActivityType>ListenAt</ActivityType></ExtendedData></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>
** И исходный запрос, который я делаю, выглядит следующим образом **
POST http://localhost:2947/test/ HTTP/1.1
User-Agent: Fiddler
Host: localhost:2947
Content-Length: 150732
/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8AAEQgDAgQAAwERAAIRAQMR...(on and on and on..lol)
Любая помощь очень ценится!