【转自】WCF配置文件注释
1
<?xml version="1.0" encoding="utf-8" ?>
2
3
<configuration>
4
5
<system.ServiceModel>
6
7
<!-- services 元素包含应用中驻留的所有service的配置要求 -->
8
9
<services>
10
11
<!-- 每个服务的配置
12
13
属性说明:
14
15
name - 指定这个service配置是针对的那个服务,为一个实现了某些Contract的服务类的完全限定名
16
17
(名称空间.类型名),ServiceHost载入一个服务后,会到配置文件中的<services>下找有没有
18
19
name属性跟服务匹配的<service>的配置
20
21
behaviorConfiguration - 指定在<serviceBehaviors>下的一个<behavior>的name,这个特定<behavior>
22
23
给这个service制定了一些行为,比如服务是否允许身份模拟-->
24
25
<service name="名称空间.类型名" behaviorConfiguration="behavior名">
26
27
<host>
28
29
<baseAddresses>
30
31
<!-- 在此可以定义每种传输协议的baseAddress,用于跟使用同样传输协议Endpoint定义的相对地
32
33
址组成完整的地址,但是每种传输协议只能定义一个baseAddress。HTTP的baseAddress同时是service
34
35
对外发布服务说明页面的URL-->
36
37
<add baseAddress="http://address" />
38
39
</baseAddresses>
40
41
<timeouts></timeouts>
42
43
</host>
44
45
<!-- 每个服务可以有多个Endpoint,下面<endpoint>元素对每个Endpoint分别进行配置
46
47
属性说明:
48
49
address - 指定这个Endpoint对外的URI,这个URI可以是个绝对地址,也可以是个相对于baseAddress的
50
51
相对地址。如果此属性为空,则这个Endpoint的地址就是baseAddress
52
53
binding - 指定这个Endpoint使用的binding,这个banding可以是系统预定义的9个binding之一,
54
55
比如是basicHttpBinding,也可以是自定义的customBinding。binding决定了通讯的类型、
56
57
安全、如何编码、是否基于session、是否基于事务等等
58
59
contract - 指定这个Endpoint对应的Contract的全限定名(名称空间.类型名),这个Contract应该被
60
61
service元素的name指定的那个service实现
62
63
bindingConfiguration - 指定一个binding的配置名称,跟<bindings>下面同类<binding>的name匹配
64
65
behaviorConfiguration - 指定这个endpoint的behavior,指向<behaviors>下的同样配置名称的<endpointBehaviors>
66
67
name - Endpoint的名称,可选属性,每个Contract都可以有多个Endpoint,但是每个Contract对应的
68
69
多个Endpoint名必须是唯一的-->
70
71
<endpoint address="URI" binding="basicHttpBinding" contract="Contract全限定名" bindingConfiguration="binding名" behaviorConfiguration="String" name="">
72
73
<!-- 用户定义的xml元素集合,一般用作SOAP的header内容-->
74
75
<headers>
76
77
<!-- 任何xml内容 -->
78
79
</headers>
80
81
</endpoint>
82
83
</service>
84
85
</services>
86
87
88
89
<bindings>
90
91
<!-- 指定一个或多个系统预定义的binding,比如<basicHttpBinding>,当然也可以指定自定义的customBinding,
92
93
然后在某个指定的binding下建立一个或多个配置,以便被Endpoint来使用这些配置 -->
94
95
<basicHttpBinding>
96
97
<!-- 某一类的binding的下面可能有多个配置,binding元素的name属性标识某个binding-->
98
99
<binding name="binding名">
100
101
</binding>
102
103
</basicHttpBinding>
104
105
</bindings>
106
107
<!-- 定义service和Endpiont行为-->
108
109
<behaviors>
110
111
<!-- 定义service的行为-->
112
113
<serviceBehaviors>
114
115
<!-- 一个或多个系统提供的或定制的behavior元素
116
117
属性说明:
118
119
name - 一个behavior唯一标识,<service>元素下<endpoint>的behaviorConfiguration属性指向这个name-->
120
121
<behavior name="此Behavior名称">
122
123
<!-- 指定service元数据发布和相关信息
124
125
属性说明:
126
127
httpGetEnabled - bool类型的值,表示是否允许通过HTTP的get方法获取sevice的WSDL元数据
128
129
httpGetUrl - 如果httpGetEnabled为true,这个属性指示使用哪个URL地址发布服务的WSDL,
130
131
如果这个属性没有设置,则使用服务的HTTP类型的baseAddress后面加上?WSDL-->
132
133
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://URI:port/address" />
134
135
<!--指定验证服务端的凭据-->
136
137
<serviceCredentials>
138
139
<!--指定服务端的证书
140
141
属性说明:
142
143
storeName - 证书的存储区,可能值为:AddressBook,AuthRoot,CertificateAuthority
144
145
Disallowed,My,Root,TrustedPeople,TrustedPublisher
146
147
storeLocation - 证书存储位置,可能值为:CurrentUser,LocalMachine
148
149
x509FindType - 查找证书的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName

150
151
findValue - 对应查找方式的要查找证书的值 -->
152
153
<serviceCertificate storeName="存储区" storeLocation="存储位置" x509FindType="FindBySubjectName" findValue="server1" />
154
155
</serviceCredentials>
156
157
158
159
</behavior>
160
161
</serviceBehaviors>
162
163
<!-- 定义Endpiont的行为-->
164
165
<endpointBehaviors>
166
167
<!-- 一个或多个系统提供的或定制的behavior元素
168
169
属性说明:
170
171
name - 一个behavior唯一标识,<client>元素下<endpoint>的behaviorConfiguration属性指向这个name-->
172
173
<behavior name="此Behavior名称">
174
175
<!--指定客户端的凭据-->
176
177
<clientCredentials>
178
179
<!--指定客户端的证书
180
181
属性说明:
182
183
storeName - 证书的存储区,可能值为:AddressBook,AuthRoot,CertificateAuthority
184
185
Disallowed,My,Root,TrustedPeople,TrustedPublisher
186
187
storeLocation - 证书存储位置,可能值为:CurrentUser,LocalMachine
188
189
x509FindType - 查找证书的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName

190
191
findValue - 对应查找方式的要查找证书的值 -->
192
193
<clientCertificate storeName="存储区" storeLocation="存储位置" x509FindType="FindBySubjectName" findValue="Client1" />
194
195
<serviceCertificate>
196
197
<authentication certificateValidationMode="None" />
198
199
</serviceCertificate>
200
201
</clientCredentials>
202
203
</behavior>
204
205
</endpointBehaviors>
206
207
</behaviors>
208
209
<!-- 包含客户端跟服务端连接使用到的Endpoint的配置 -->
210
211
<client>
212
213
<!-- 每个客户端Endpoint设置
214
215
属性说明:
216
217
address - 对应到服务端这个Endpoint的address
218
219
binding - 指定这个Endpoint使用的binding,这个banding可以是系统预定义的9个binding之一,
220
221
比如是basicHttpBinding
222
223
contract - 指定这个Endpoint对应的Contract的全限定名(名称空间.类型名)
224
225
name - Endpoint的配置名,客户端代理类的构造方法中的endpointConfigurationName对应到这个name
226
227
bindingConfiguration - 指定客户端binding的具体设置,指向<bindings>元素下同类型binding的name
228
229
behaviorConfiguration - 指定这个endpoint的behavior,指向<behaviors>下的同样配置名称的<endpointBehaviors>-->
230
231
<endpoint address="URI" binding="basicHttpBinding" bindingConfiguration="binding名" behaviorConfiguration="String" contract="Contract全限定名" name="endpoint配置名" >
232
233
<!-- 用于客户端验证服务端身份,可选以下一种方式验证服务端-->
234
235
<identity>
236
237
<userPrincipalName></userPrincipalName>
238
239
<servicePrincipalName></servicePrincipalName>
240
241
<!--如果客户端验证是windows,这里指定DNS名;如果是Certificate,这里指定证书subject name-->
242
243
<dns></dns>
244
245
<rsa></rsa>
246
247
<!--指定服务端证书的公钥
248
249
属性说明:
250
251
encodedValue - 服务端证书的公钥的base64编码,用于加密用户名和密码-->
252
253
<certificate encodedValue=""></certificate>
254
255
<!-- 用户指定在客户端证书存储区内的服务端证书
256
257
属性说明:
258
259
storeName - 证书的存储区,可能值为:AddressBook,AuthRoot,CertificateAuthority
260
261
Disallowed,My,Root,TrustedPeople,TrustedPublisher
262
263
storeLocation - 证书存储位置,可能值为:CurrentUser,LocalMachine
264
265
x509FindType - 查找证书的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName

266
267
findValue - 对应查找方式的要查找证书的值 -->
268
269
<certificateReference storeName="存储区" storeLocation="存储位置" x509FindType="FindBySubjectName" findValue="Client1" />
270
271
</identity>
272
273
</endpoint>
274
275
</client>
276
277
</system.ServiceModel>
278
279
</configuration>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149



150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189



190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265



266

267

268

269

270

271

272

273

274

275

276

277

278

279
