Итак, я рассмотрел большое количество сообщений об одной и той же проблеме, и по какой-то причине я не могу получить рабочую версию с моей стороны, даже используя существующие решения этих вопросов.Может ли кто-то пролить свет на то, что я пропускаю?Это почти связано с проблемой размера файла, превышающей 64 КБ, поскольку я вижу ошибку почти мгновенно, как только я пытаюсь передать файл выше этого размера.
Вот файл web.config моей службы WCF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
<sessionState timeout="60" />
<httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true" executionTimeout="14400"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name="FileManager" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="FileManagerBehavior" name="PrimeWebServices.FileManager">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="FileManager" contract="PrimeWebServices.IFileManager"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="FileManagerBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
и вот мой код службы WCF, стоящий за
namespace PrimeWebServices
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "FileManager" in code, svc and config file together.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class FileManager : IFileManager
{
public FileManager()
{
HttpContext httpContext = HttpContext.Current;
if (httpContext != null)
{
httpContext.Response.BufferOutput = false;
}
}
public string UploadStream(Stream stream)
{
...
}
}
}
Наконец, вот настройки конфигурации клиента (это клиент winforms, использующий ссылку на службу)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileManager" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1116/FileManager.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IFileManager" contract="PrimeWebServices.IFileManager"
name="BasicHttpBinding_IFileManager" />
</client>
</system.serviceModel>
</configuration>
приложение работает нормально, если размер файла не превышает 64 КБ. Я вижу, что другие сообщают, что заставляет меня поверить, что я просто неправильно что-то подключаю и возвращаюсь к настройке конфигурации по умолчанию.