我有以下 wcf 服务方法,它采用 Attachment 对象,并且 Attachment 类定义是:
[DataContract]
public class Attachment
{
[DataMember]
public int AttachmentId { get; set; }
[DataMember]
public String DMSFileId { get; set; }
[DataMember]
public String FileName { get; set; }
[DataMember]
public int? FileSize { get; set; }
[DataMember]
public String FileSource { get; set; }
[DataMember]
public byte[] File { get; set; }
}
方法定义是:
[OperationContract]
public int AddAttachment(DataTypes.Administration.Attachment attachment)
{
return AttachmentBusinessLogic.AddAttachment(attachment);
}
调用该方法时,出现以下异常:远程服务器返回意外响应:(413)请求实体太大
谷歌搜索我遇到了许多绑定配置的错误,但它们都没有工作,不是 maxReceivedMessageSize 也不是 readerQuotas。
这是服务和客户端的 Web 配置:
服务
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
客户
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="AdministrationBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAdministrationService" sendTimeout="00:05:00"
openTimeout="00:05:00"
receiveTimeout="00:05:00"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8001/AdministrationService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAdministrationService" contract="AdministrationService.IAdministrationService" name="BasicHttpBinding_IAdministrationService" behaviorConfiguration="AdministrationBehavior" />
</client>
</system.serviceModel>
请提供有关如何克服此异常的任何建议。