WCF配置文件详解 【转】

?
1
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
<?xml version= "1.0"  encoding= "utf-8"  ?>
 
<configuration>
     <!-- <system.ServiceModel> section -->
     <system.ServiceModel>
         <!-- services 元素包含应用中驻留的所有service的配置要求 -->
         <services>
             <!-- 每个服务的配置
              属性说明: 
              name - 指定这个service配置是针对的那个服务,为一个实现了某些Contract的服务类的完全限定名
                    (名称空间.类型名),ServiceHost载入一个服务后,会到配置文件中的<services>下找有没有
                    name属性跟服务匹配的<service>的配置 
              behaviorConfiguration - 指定在<serviceBehaviors>下的一个<behavior>的name,这个特定<behavior>
                                      给这个service制定了一些行为,比如服务是否允许身份模拟-->
             <service name= "名称空间.类型名"  behaviorConfiguration= "behavior名" >
                 <!-- 每个服务可以有多个Endpoint,下面<endpoint>元素对每个Endpoint分别进行配置
                  属性说明: 
                  address - 指定这个Endpoint对外的URI,这个URI可以是个绝对地址,也可以是个相对于baseAddress的
                            相对地址。如果此属性为空,则这个Endpoint的地址就是baseAddress
                  binding - 指定这个Endpoint使用的binding,这个banding可以是系统预定义的9个binding之一,
                            比如是basicHttpBinding,也可以是自定义的customBinding。binding决定了通讯的类型、
                            安全、如何编码、是否基于session、是否基于事务等等
                  contract - 指定这个Endpoint对应的Contract的全限定名(名称空间.类型名),这个Contract应该被
                             service元素的name指定的那个service实现 
                  bindingConfiguration - 指定一个binding的配置名称,跟<bindings>下面同类<binding>的name匹配
                  name - Endpoint的名称,可选属性,每个Contract都可以有多个Endpoint,但是每个Contract对应的
                         多个Endpoint名必须是唯一的-->
                 <endpoint address= "URI"  binding= "basicHttpBinding"  contract= "Contract全限定名"  bindingConfiguration= "binding名"  name= "" >
                     <!-- 用户定义的xml元素集合,一般用作SOAP的header内容-->
                     <headers>
                         <!-- 任何xml内容 -->
                     </headers>
                     <identity>
                         <!-- <identity>下的元素都是可选的-->
                         <userPrincipalName></userPrincipalName>
                         <servicePrincipalName></servicePrincipalName>
                         <dns></dns>
                         <rsa></rsa>
                         <certificate encodedValue= "" ></certificate>
                         <!-- <certificateReference>的属性都是可选的
                          属性说明:
                          storeName - 证书的存储区,可能值为:AddressBook,AuthRoot,CertificateAuthority
                                      Disallowed,My,Root,TrustedPeople,TrustedPublisher
                          storeLocation - 证书存储位置,可能值为:CurrentUser,LocalMachine-->
                         <certificateReference storeName= ""  storeLocation= "" >
                         </certificateReference>
                     </identity>
                 </endpoint>
                 <host>
                     <baseAddresses>
                         <!-- 在此可以定义每种传输协议的baseAddress,用于跟使用同样传输协议Endpoint定义的相对地
                     址组成完整的地址,但是每种传输协议只能定义一个baseAddress。HTTP的baseAddress同时是service
                     对外发布元数据的URL-->
                         <add baseAddress= "http://address"  />
                     </baseAddresses>
                     <timeouts></timeouts>
                 </host>
             </service>
         </services>
  
         <bindings>
             <!-- 指定一个或多个系统预定义的binding,比如<basicHttpBinding>,当然也可以指定自定义的customBinding,
              然后在某个指定的binding下建立一个或多个配置,以便被Endpoint来使用这些配置 -->
             <basicHttpBinding>
                 <!-- 某一类的binding的下面可能有多个配置,binding元素的name属性标识某个binding-->
                 <binding name= "binding名" >
                 </binding>
             </basicHttpBinding>
         </bindings>
         <!-- 定义service和Endpiont行为-->
         <behaviors>
             <!-- 定义service的行为-->
             <serviceBehaviors>
                 <!-- 一个或多个系统提供的或定制的behavior元素
                  属性说明:
                  name - 一个behavior唯一标识,<service>元素的behaviorConfiguration属性指向这个name-->
                 <behavior name= "" >
                     <!-- 指定service元数据发布和相关信息
                      属性说明:
                      httpGetEnabled -  bool 类型的值,表示是否允许通过HTTP的 get 方法获取sevice的WSDL元数据
                      httpGetUrl - 如果httpGetEnabled为 true ,这个属性指示使用哪个URL地址发布服务的WSDL,
                                   如果这个属性没有设置,则使用服务的HTTP类型的baseAddress后面加上?WSDL-->
                     <serviceMetadata httpGetEnabled= "true"  httpGetUrl= "http://URI:port/address"  />
                 </behavior>
             </serviceBehaviors>
             <!-- 定义Endpiont的行为-->
             <endpointBehaviors>
             </endpointBehaviors>
         </behaviors>
         <!-- 包含客户端跟服务端连接使用到的Endpoint的配置 -->
         <client>
             <!-- 每个客户端Endpoint设置
              属性说明:
              address - 对应到服务端这个Endpoint的address
              binding - 指定这个Endpoint使用的binding,这个banding可以是系统预定义的9个binding之一,
                        比如是basicHttpBinding
              contract - 指定这个Endpoint对应的Contract的全限定名(名称空间.类型名)
              name - Endpoint的配置名,客户端代理类的构造方法中的endpointConfigurationName对应到这个name
              bindingConfiguration - 指定客户端binding的具体设置,指向<bindings>元素下同类型binding的name -->
             <endpoint address= "URI"
                 binding= "basicHttpBinding"  bindingConfiguration= "binding名"
                 contract= "Contract全限定名"  name= "endpoint配置名"  />
         </client>
     </system.ServiceModel>
</configuration>

转自 Weichuo

转载于:https://www.cnblogs.com/wipphj/p/3880429.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值