WCF配置文件

<?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 >

转载于:https://www.cnblogs.com/zhl7522/archive/2008/02/03/1063716.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值