【转】wcf configuration

http://blog.csdn.net/zhongjiekangping/article/details/4858230
 
1.	ServiceHost:配置 
2.	
3.	
4.	
5.	1 <?xml version="1.0" encoding="utf-8" ?> 
6.	2 <configuration> 
7.	3 <!--<system.ServiceModel> section --> 
8.	4 <system.ServiceModel> 
9.	5 <!-- services 节点中包含着所有Service的配置说明 --> 
10.	6 <services> 
11.	7 <!-- 第一个服务的配置开始都是一个<service ****>节点 
12.	8 相关属性解释: 
13.	9 name - 指定这个service配置是针对的哪一个WCF服务的 
14.	10 (名称空间.类型名),ServiceHost载入一个服务后,会到配置文件中的<services>下找有没有 
15.	11 name属性跟服务匹配的<service>的配置 
16.	12 behaviorConfiguration - 指定在<serviceBehaviors>下的一个<behavior>的name,这个特定<behavior> 
17.	13 给这个service制定了一些行为,比如服务是否允许身份模拟--> 
18.	14 <service name="NameSpace.ClassName" behaviorConfiguration="BehaviorName"> 
19.	15 <!-- 每个服务可以有多个Endpoint,下面<endpoint>元素对每个Endpoint分别进行配置 
20.	16 属性说明: 
21.	17 address - 指定这个Endpoint对外的URI,这个URI可以是个绝对地址,也可以是个相对于baseAddress的 
22.	18 相对地址。如果此属性为空,则这个Endpoint的地址就是baseAddress 
23.	19 binding - 指定这个Endpoint使用的binding,这个banding可以是系统预定义的9个binding之一, 
24.	20 比如是basicHttpBinding,也可以是自定义的customBinding。binding决定了通讯的类型、 
25.	21 安全、如何编码、是否基于session、是否基于事务等等 
26.	22 contract - 指定这个Endpoint对应的Contract的全限定名(名称空间.类型名),这个Contract应该被 
27.	23 service元素的name指定的那个service实现 
28.	24 bindingConfiguration - 指定一个binding的配置名称,跟<bindings>下面同类<binding>的name匹配 
29.	25 name - Endpoint的名称,可选属性,每个Contract都可以有多个Endpoint,但是每个Contract对应的 
30.	26 多个Endpoint名必须是唯一的--> 
31.	27 <endpoint address="URI" binding="basicHttpBinding" contract="Contract全限定名" bindingConfiguration="binding名" name=""> 
32.	28 <!-- 用户定义的xml元素集合,一般用作SOAP的header内容--> 
33.	29 <headers> 
34.	30 <!-- 任何xml内容 --> 
35.	31 </headers> 
36.	32 <identity> 
37.	33 <!--<identity>下的元素都是可选的--> 
38.	34 <userPrincipalName></userPrincipalName> 
39.	35 <servicePrincipalName></servicePrincipalName> 
40.	36 <dns></dns> 
41.	37 <rsa></rsa> 
42.	38 <certificate encodedValue=""></certificate> 
43.	39 <!--<certificateReference>的属性都是可选的 
44.	40 属性说明: 
45.	41 storeName - 证书的存储区,可能值为:AddressBook,AuthRoot,CertificateAuthority 
46.	42 Disallowed,My,Root,TrustedPeople,TrustedPublisher 
47.	43 storeLocation - 证书存储位置,可能值为:CurrentUser,LocalMachine--> 
48.	44 <certificateReference storeName="" storeLocation=""> 
49.	45 </certificateReference> 
50.	46 </identity> 
51.	47 </endpoint> 
52.	48 <host> 
53.	49 <baseAddresses> 
54.	50 <!-- 在此可以定义每种传输协议的baseAddress,用于跟使用同样传输协议Endpoint定义的相对地 
55.	51 址组成完整的地址,但是每种传输协议只能定义一个baseAddress。HTTP的baseAddress同时是service 
56.	52 对外发布元数据的URL--> 
57.	53 <add baseAddress="http://address" /> 
58.	54 </baseAddresses> 
59.	55 <timeouts></timeouts> 
60.	56 </host> 
61.	57 </service> 
62.	58 </services> 
63.	59 <!--绑定配置--> 
64.	60 <bindings> 
65.	61 <!-- 指定一个或多个系统预定义的binding,比如<basicHttpBinding>,当然也可以指定自定义的customBinding, 
66.	62 然后在某个指定的binding下建立一个或多个配置,以便被Endpoint来使用这些配置 --> 
67.	63 <basicHttpBinding> 
68.	64 <!-- 某一类的binding的下面可能有多个配置,binding元素的name属性标识某个binding--> 
69.	65 <binding name="binding名"> 
70.	66 </binding> 
71.	67 </basicHttpBinding> 
72.	68 </bindings> 
73.	69 <!-- 定义service和Endpiont行为--> 
74.	70 <behaviors> 
75.	71 <!-- 定义service的行为--> 
76.	72 <serviceBehaviors> 
77.	73 <!-- 一个或多个系统提供的或定制的behavior元素 
78.	74 属性说明: 
79.	75 name - 一个behavior唯一标识,<service>元素的behaviorConfiguration属性指向这个name--> 
80.	76 <behavior name=""> 
81.	77 <!-- 指定service元数据发布和相关信息 
82.	78 属性说明: 
83.	79 httpGetEnabled - bool类型的值,表示是否允许通过HTTP的get方法获取sevice的WSDL元数据 
84.	80 httpGetUrl - 如果httpGetEnabled为true,这个属性指示使用哪个URL地址发布服务的WSDL, 
85.	81 如果这个属性没有设置,则使用服务的HTTP类型的baseAddress后面加上?WSDL--> 
86.	82 <serviceMetadata httpGetEnabled="true" httpGetUrl="http://URI:port/address" /> 
87.	83 </behavior> 
88.	84 </serviceBehaviors> 
89.	85 <!-- 定义Endpiont的行为--> 
90.	86 <endpointBehaviors> 
91.	87 </endpointBehaviors> 
92.	88 </behaviors> 
93.	89 <!-- 包含客户端跟服务端连接使用到的Endpoint的配置 --> 
94.	90 <client> 
95.	91 <!-- 每个客户端Endpoint设置 
96.	92 属性说明: 
97.	93 address - ServiceHost的这个Endpoint的address 
98.	94 binding - 指定这个Endpoint使用的binding,这个binding可以是系统预定义的9个binding之一, 
99.	95 比如是basicHttpBinding 
100.	96 contract - 指定这个Endpoint对应的Contract的全限定名(名称空间.类型名) 
101.	97 name - Endpoint的名称,客户端代理类的构造方法中的endpointConfigurationName对应到这个name 
102.	98 bindingConfiguration - 指定客户端binding的具体设置,指向<bindings>元素下同类型binding的name --> 
103.	99 <!--如果此处有多个endpoint,系统会默认使用最后一个endpoint的配置--> 
104.	100 <endpoint address="URI" 
105.	101 binding="basicHttpBinding" bindingConfiguration="binding名" 
106.	102 contract="Contract全限定名" name="endpoint配置名" /> 
107.	103 </client> 
108.	104 </system.ServiceModel> 
109.	105 </configuration> 
110.	
111.	
112.	
113.	ServiceClient:配置 (如果我们是在一个项目中添加了WCF引用时,系统会在app.config或者是web.config文件中添加一些相应的配置) 
114.	
115.	
116.	1 <system.serviceModel> 
117.	2 <bindings> 
118.	3 <wsHttpBinding> 
119.	4 <binding name="WSHttpBinding_ICPWService" closeTimeout="00:01:00" 
120.	5 openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
121.	6 bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
122.	7 maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
123.	8 textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
124.	9 <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
125.	10 maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
126.	11 <reliableSession ordered="true" inactivityTimeout="00:10:00" 
127.	12 enabled="false" /> 
128.	13 <security mode="None"> 
129.	14 <transport clientCredentialType="Windows" proxyCredentialType="None" 
130.	15 realm="" /> 
131.	16 <message clientCredentialType="Windows" negotiateServiceCredential="true" 
132.	17 establishSecurityContext="true" /> 
133.	18 </security> 
134.	19 </binding> 
135.	20 </wsHttpBinding> 
136.	21 </bindings> 
137.	22 <client> 
138.	23 <endpoint address="http://xxx.xxx.com/wcf/Service.svc" 
139.	24 binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" 
140.	25 contract="Namespace.IService" name="endpointname" /> 
141.	26 </client> 
142.	27 </system.serviceModel> 

原文地址:https://www.cnblogs.com/gossip/p/2384196.html