WCF配置文件相关操作技巧解析

开发 开发工具
WCF配置文件只要做一下简单的修改操作,就可以帮助我们实现上传数据大小的限制。希望大家通过本文介绍的内容就可以掌握这一技巧应用。

如何运用WCF实现上传数据大小的控制,取决于我们对WCF配置文件的修改方法。在这里就为大家详细介绍一下WCF配置文件的一些修改技巧,以达到文件大小控制的目的。#t#

默认情况下,wcf的服务端如果发生异常是不会将详细异常发送给客户端的,客户端只能提到以下笼络的提示异常信息:

由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 配置行为)以便将异常信息发送回客户端,或在打开每个 Microsoft .NET Framework 3.0 SDK 文档的跟踪的同时检查服务器跟踪日志。

于是做了一下修改:

  1. [ServiceBehavior(AddressFilterMode
    AddressFilterMode = AddressFilterMode.
    Any, 
    IncludeExceptionDetailInFaults = true)]  
  2. public class CommunicationWithUnit : 
    IContractForUnit  
  3. {...} 

 

其中第一个是去防火墙的,第二个是客户端显示错误详细信息的。

 

主要还是数据大小问题,于是又去解决:

在WCF配置文件进行修改.

旧的WCF配置文件:

 

< binding name="BasicHttpBinding_
ICentaMiddleService"
 closeTimeout="00:01:00" 
openTimeout="00:01:00" receiveTimeout=
"00:10:00" sendTimeout="00:01:00"  allowCookies="false" bypassProxyOnLocal=
"false" hostNameComparisonMode="StrongWildcard"  maxBufferSize="65536" maxBuffer
PoolSize
="524288" maxReceivedMessageSize="65536"  messageEncoding="Text" textEncoding=
"utf-8" transferMode="Buffered"  useDefaultWebProxy="true">  < readerQuotas maxDepth="32" 
maxStringContentLength="8192" 
maxArrayLength="16384"  maxBytesPerRead="4096" maxName
TableCharCount
="16384" />  < security mode="None">  < transport clientCredentialType=
"None" proxyCredentialType="None"  realm="" />  < message clientCredentialType=
"UserName" algorithmSuite="Default" />  < /security>  < /binding> 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.

 

新的WCF配置文件:

 

< binding name="BasicHttpBinding_
ICentaMiddleService"
 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="9223372036854775807"  messageEncoding="Text" textEncoding=
"utf-8" transferMode="Streamed"  useDefaultWebProxy="true">  < readerQuotas maxDepth="6553500" 
maxStringContentLength="2147483647"  maxArrayLength="6553500" maxBytesPerRead=
"6553500" maxNameTableCharCount="6553500" />  < security mode="None">  < transport clientCredentialType="None"
 proxyCredentialType="None"  realm="" />  < message clientCredentialType="UserName" 
algorithmSuite="Default" />  < /security>  < /binding> 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.

 

以上就是针对文件上传大小控制对WCF配置文件进行的修改方法。

责任编辑:曹凯 来源: 百度博客
相关推荐

2010-02-22 10:18:18

WCF配置文件

2010-02-23 14:17:20

WCF配置文件

2010-02-23 17:30:41

WCF部署于IIS

2010-02-24 14:10:54

WCF修改App.co

2009-11-05 10:30:41

WCF Address

2009-12-21 13:06:05

WCF Address

2010-02-22 17:58:06

WCF异步上传

2011-03-28 09:07:26

Nagios配置文件

2009-11-09 13:31:09

WCF服务端配置

2022-11-10 09:05:18

Lua配置文件

2010-02-24 11:22:04

WCF方法重载

2021-07-05 12:09:58

Python编程语言

2010-03-01 17:39:07

WCF Address

2010-03-19 11:18:07

Python读写配置文

2010-11-12 09:44:59

Cassandra配置

2010-02-26 16:05:14

寄宿WCF服务

2009-12-21 18:10:50

WCF实现事件通知

2010-03-30 18:04:45

Nginx http服

2009-06-24 08:57:14

InittabLinux配置

2021-07-13 05:47:40

GroovyJSON软件开发
点赞
收藏

51CTO技术栈公众号