【发布时间】:2018-08-08 12:25:36
【问题描述】:
刚刚创建了一个将文件作为缓冲区/流发送到客户端的 WCF 服务。并使用客户项目对其进行测试。首先;当我在 localhost 上调试服务时,出现该错误:
已超出传入邮件的最大邮件大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性
由于我从 WCF 测试工具中增加了 Client.config 的 maxBufferSize 和 maxReceivedMessageSize 值;错误消失了。服务返回完整大小的缓冲区。
然后我在发布到文件系统后通过复制粘贴将服务发布到远程服务器。从服务器调试并调用相同的函数时;服务返回空缓冲区。
这是我的 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>
还有一个类似的问题:
在服务合同接口下方定义了一个枚举:
[DataContract]
[ServiceKnownType(typeof(FileType))]
public static class CompositeType
{
public enum FileType
{
[EnumMember]
SystemFile = 1,
[EnumMember]
Physical = 2,
[EnumMember]
Invalid = 3,
[EnumMember]
Other = 4
}
}
其中一个 WCF 函数返回带有字符串值和 FileType 对象的 List。本地测试没有问题; List 的返回值有几个元素,但远程服务器上的相同函数返回一个空 List。还无法修复,需要帮助。
我是否错过了远程服务器的 web.config 或 IIS 上的设置?是关于服务器的权限吗?我应该对我的代码进行任何更改吗? (文件系统和数据库凭据正确,其他功能正常)
ps。对不起,如果我违反了输入格式的规则。
【问题讨论】:
标签: c# wcf enums buffer iis-8.5