简体   繁体   English

将Wcf服务发布到远程服务器后,缓冲区大小错误

[英]Buffer Size Error after publishing Wcf Service to a Remote Server

Just created a WCF Service that sends files to clients as buffer/stream. 刚刚创建了WCF服务,该服务将文件作为缓冲区/流发送到客户端。 And testing it with a client project. 并使用客户项目对其进行测试。 At first; 首先; when I debug the service on localhost, got that error: 当我在localhost上调试服务时,收到该错误:

The maximum message size quota for incoming messages (65536) has been exceeded. 超出了传入消息的最大消息大小配额(65536)。 To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element 要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性

Since I increased the maxBufferSize and maxReceivedMessageSize values of Client.config from WCF Test Tool; 由于我从WCF测试工具增加了Client.config的maxBufferSize和maxReceivedMessageSize值; the error was gone. 错误消失了。 Service returns the buffer with full size. 服务返回完整大小的缓冲区。

Then I published the service to the remote server via copy&paste after publishing to file system. 然后,在发布到文件系统后,我通过复制和粘贴将服务发布到远程服务器。 When debugging from server and calling the same function; 从服务器调试并调用相同的函数时; service returns empty buffer. 服务返回空缓冲区。

Here is my web.config: 这是我的web.config:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation targetFramework="4.5.2" debug="true"/>
    <httpRuntime targetFramework="4.5.2" maxRequestLength="67108864"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="LargeBufferBehavior">
          <!-- 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"/>
          <dataContractSerializer maxItemsInObjectGraph="67108864"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IFileOperationService" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="524288" maxBufferSize="67108864" maxReceivedMessageSize="67108864" transferMode="StreamedRequest">
          <readerQuotas maxDepth="67108864" maxStringContentLength="67108864" maxArrayLength="67108864" maxBytesPerRead="67108864" maxNameTableCharCount="67108864"/>
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <services>
      <service behaviorConfiguration="LargeBufferBehavior" name="EbysIntegrationService.FileOperationService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileOperationService" contract="EbysIntegrationService.IFileOperationService"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <client>
      <endpoint address=""
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileOperationService"
          contract="EbysIntegrationService.IFileOperationService"
          name="BasicHttpBinding_IFileOperationService" />
    </client>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

One more problem similar to this: 与此类似的另一个问题:

Defined an enum just below the Service Contract Interface: 在服务合同界面下方定义了一个枚举:

[DataContract]
[ServiceKnownType(typeof(FileType))]
public static class CompositeType
{
    public enum FileType
    { 
        [EnumMember]
        SystemFile = 1,
        [EnumMember]
        Physical = 2,
        [EnumMember]
        Invalid = 3,
        [EnumMember]
        Other = 4
    }
}

One of the WCF functions returns List with a string value and a FileType object. WCF函数之一返回具有字符串值和FileType对象的List。 No problem on local test; 本地测试没问题; return value of List has several elements but the same function on the remote server returns an empty List. List的返回值包含多个元素,但是远程服务器上的相同功能返回一个空的List。 Can't fix it yet and need help. 尚无法解决,需要帮助。


Do I miss a setting on web.config or IIS of remote server? 我会错过远程服务器的web.config或IIS上的设置吗? Is it about the permissions of server? 与服务器的权限有关吗? Should I make any change on my codes? 我应该对代码进行任何更改吗? (File System and Database cridentials are correct, other functions are working correctly) (文件系统和数据库凭据正确,其他功能正常运行)

ps. PS。 Sorry If I break the rules of typing format. 抱歉,如果我违反了输入格式的规则。

You have to increase the maxBufferSize on server to resolve this error. 您必须在服务器上增加maxBufferSize才能解决此错误。

<bindings>
<basicHttpBinding>
    <binding name="basicHttp" allowCookies="true"
             maxReceivedMessageSize="20000000" 
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
        <readerQuotas maxDepth="32" 
             maxArrayLength="200000000"
             maxStringContentLength="200000000"/>
    </binding>
</basicHttpBinding>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF服务中的缓冲区大小 - Buffer size in WCF service 远程服务器返回错误:NotFound WCF服务 - The remote server returned an error: NotFound WCF Service 使用BasicHttpBinding为远程客户端发布Wcf服务 - Publishing a Wcf service using BasicHttpBinding for remote clients 仅在发布WCF服务器之后才自动映射错误映射类型 - Automapper Error mapping types only after publishing WCF server 执行服务方法后的WCF。 System.ServiceModel.CommunicationException:远程服务器返回错误:NotFound - WCF after executing service method. System.ServiceModel.CommunicationException: The remote server returned an error: NotFound 发布后WCF服务无法连接 - WCF service doesn't connect after publishing 从核心 API 调用 WCF 服务导致错误:缓冲 XML 内容所需的大小超出了缓冲区配额 - Calling WCF service from Core API results in error: The size necessary to buffer the XML content exceeded the buffer quota 被“远程服务器返回错误:(403)禁止”与WCF服务在https中难倒 - Stumped by “The remote server returned an error: (403) Forbidden” with WCF Service in https wcf服务远程服务器返回错误(400)错误的请求 - wcf service the remote server returned an error (400) bad request 发布WCF后出现FaultException错误 - Getting FaultException error after publishing WCF
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM