WCF配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
? <system.ServiceModel>
? ? <!-- services元素包含應用中駐留的所有service的配置要求-->
? ? <services>
? ? ? <!-- 每個服務的配置
? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? name -指定這個service配置是針對的那個服務,為一個實現了某些Contract的服務類的完全限定名
? ? ? ? ? ? ? ? ? (名稱空間.類型名),ServiceHost載入一個服務后,會到配置文件中的<services>下找有沒有
? ? ? ? ? ? ? ? ? name屬性跟服務匹配的<service>的配置?
? ? ? ? ? ? behaviorConfiguration -指定在<serviceBehaviors>下的一個<behavior>的name,這個特定<behavior>給這個service制定了一些行為,比如服務是否允許身份模擬-->
? ? ? <service name="名稱空間.類型名" behaviorConfiguration="behavior名">
? ? ? ? <host>
? ? ? ? ? <baseAddresses>
? ? ? ? ? ? <!-- 在此可以定義每種傳輸協議的baseAddress,用于跟使用同樣傳輸協議Endpoint定義的相對地址組成完整的地址,但是每種傳輸協議只能定義一個baseAddress。HTTP的baseAddress同時是service 對外發布服務說明頁面的URL-->
? ? ? ? ? ? <add baseAddress="http://address" />
? ? ? ? ? </baseAddresses>
? ? ? ? ? <timeouts></timeouts>
? ? ? ? </host>
? ? ? ? <!-- 每個服務可以有多個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匹配
? ? ? ? ? ? ? ? ? ?behaviorConfiguration -指定這個endpoint的behavior,指向<behaviors>下的同樣配置名稱的<endpointBehaviors>
? ? ? ? ? ? ? ? name - Endpoint的名稱,可選屬性,每個Contract都可以有多個Endpoint,但是每個Contract對應的
? ? ? ? ? ? ? ? ? ? ? ?多個Endpoint名必須是唯一的-->
? ? ? ? <endpoint address="URI" binding="basicHttpBinding" contract="Contract全限定名" bindingConfiguration="binding名" behaviorConfiguration="String" name="">
? ? ? ? ? <!-- 用戶定義的xml元素集合,一般用作SOAP的header內容-->
? ? ? ? ? <headers>
? ? ? ? ? ? <!-- 任何xml內容-->
? ? ? ? ? </headers>
? ? ? ? </endpoint>
? ? ? </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>元素下<endpoint>的behaviorConfiguration屬性指向這個name-->
? ? ? ? <behavior name="此Behavior名稱">
? ? ? ? ? <!-- 指定service元數據發布和相關信息
? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? httpGetEnabled - bool類型的值,表示是否允許通過HTTP的get方法獲取sevice的WSDL元數據
? ? ? ? ? ? ? ? ? ? httpGetUrl -如果httpGetEnabled為true,這個屬性指示使用哪個URL地址發布服務的WSDL,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?如果這個屬性沒有設置,則使用服務的HTTP類型的baseAddress后面加上?WSDL-->
? ? ? ? ? <serviceMetadata httpGetEnabled="true" httpGetUrl="http://URI:port/address" />
? ? ? ? ? <!--指定驗證服務端的憑據-->
? ? ? ? ? <serviceCredentials>
? ? ? ? ? ? <!--指定服務端的證書
? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? storeName -證書的存儲區,可能值為:AddressBook,AuthRoot,CertificateAuthority
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Disallowed,My,Root,TrustedPeople,TrustedPublisher
? ? ? ? ? ? ? ? ? ? ? ? storeLocation -證書存儲位置,可能值為:CurrentUser,LocalMachine
? ? ? ? ? ? ? ? ? ? ? ? ? ? x509FindType -查找證書的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName......
? ? ? ? ? ? ? ? ? ? ? ? ? ? findValue -對應查找方式的要查找證書的值 ? ? ? ? ? ? ? ?-->
? ? ? ? ? ? <serviceCertificate storeName="存儲區" storeLocation="存儲位置" x509FindType="FindBySubjectName" findValue="server1" />
? ? ? ? ? </serviceCredentials>
? ? ? ? </behavior>
? ? ? </serviceBehaviors>
? ? ? <!-- 定義Endpiont的行為-->
? ? ? <endpointBehaviors>
? ? ? ? <!-- 一個或多個系統提供的或定制的behavior元素
? ? ? ? ? ? ? ?屬性說明:
? ? ? ? ? ? ? ? name -一個behavior唯一標識,<client>元素下<endpoint>的behaviorConfiguration屬性指向這個name-->
? ? ? ? <behavior name="此Behavior名稱">
? ? ? ? ? <!--指定客戶端的憑據-->
? ? ? ? ? <clientCredentials>
? ? ? ? ? ? <!--指定客戶端的證書
? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? storeName -證書的存儲區,可能值為:AddressBook,AuthRoot,CertificateAuthority
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Disallowed,My,Root,TrustedPeople,TrustedPublisher
? ? ? ? ? ? ? ? ? ? ? ? storeLocation -證書存儲位置,可能值為:CurrentUser,LocalMachine
? ? ? ? ? ? ? ? ? ? ? ? ? ? x509FindType -查找證書的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName......
? ? ? ? ? ? ? ? ? ? ? ? ? ? findValue -對應查找方式的要查找證書的值 ? ? ? ? ? ? ? ?-->
? ? ? ? ? ? <clientCertificate storeName="存儲區" storeLocation="存儲位置" x509FindType="FindBySubjectName" findValue="Client1" />
? ? ? ? ? ? <serviceCertificate>
? ? ? ? ? ? ? <authentication certificateValidationMode="None" />
? ? ? ? ? ? </serviceCertificate>
? ? ? ? ? </clientCredentials>
? ? ? ? </behavior>
? ? ? </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
? ? ? ? ? ? ? behaviorConfiguration -指定這個endpoint的behavior,指向<behaviors>下的同樣配置名稱的<endpointBehaviors>-->
? ? ? <endpoint address="URI" binding="basicHttpBinding" bindingConfiguration="binding名" behaviorConfiguration="String" contract="Contract全限定名" name="endpoint配置名" >
? ? ? ? <!-- 用于客戶端驗證服務端身份,可選以下一種方式驗證服務端-->
? ? ? ? <identity>
? ? ? ? ? <userPrincipalName></userPrincipalName>
? ? ? ? ? <servicePrincipalName></servicePrincipalName>
? ? ? ? ? <!--如果客戶端驗證是windows,這里指定DNS名;如果是Certificate,這里指定證書subject name-->
? ? ? ? ? <dns></dns>
? ? ? ? ? <rsa></rsa>
? ? ? ? ? <!--指定服務端證書的公鑰
? ? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? ? ?encodedValue -服務端證書的公鑰的base64編碼,用于加密用戶名和密碼-->
? ? ? ? ? <certificate encodedValue=""></certificate>
? ? ? ? ? <!-- 用戶指定在客戶端證書存儲區內的服務端證書
? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? storeName -證書的存儲區,可能值為:AddressBook,AuthRoot,CertificateAuthority
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Disallowed,My,Root,TrustedPeople,TrustedPublisher
? ? ? ? ? ? ? ? ? ? ? ? storeLocation -證書存儲位置,可能值為:CurrentUser,LocalMachine
? ? ? ? ? ? ? ? ? ? ? ? ? ? x509FindType -查找證書的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName......
? ? ? ? ? ? ? ? ? ? ? ? ? ? findValue -對應查找方式的要查找證書的值 ? ? ? ? ? ? ? ?-->
? ? ? ? ? <certificateReference storeName="存儲區" storeLocation="存儲位置" x509FindType="FindBySubjectName" findValue="Client1" />
? ? ? ? </identity>
? ? ? </endpoint>
? ? </client>
? </system.ServiceModel>
</configuration>
<configuration>
? <system.ServiceModel>
? ? <!-- services元素包含應用中駐留的所有service的配置要求-->
? ? <services>
? ? ? <!-- 每個服務的配置
? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? name -指定這個service配置是針對的那個服務,為一個實現了某些Contract的服務類的完全限定名
? ? ? ? ? ? ? ? ? (名稱空間.類型名),ServiceHost載入一個服務后,會到配置文件中的<services>下找有沒有
? ? ? ? ? ? ? ? ? name屬性跟服務匹配的<service>的配置?
? ? ? ? ? ? behaviorConfiguration -指定在<serviceBehaviors>下的一個<behavior>的name,這個特定<behavior>給這個service制定了一些行為,比如服務是否允許身份模擬-->
? ? ? <service name="名稱空間.類型名" behaviorConfiguration="behavior名">
? ? ? ? <host>
? ? ? ? ? <baseAddresses>
? ? ? ? ? ? <!-- 在此可以定義每種傳輸協議的baseAddress,用于跟使用同樣傳輸協議Endpoint定義的相對地址組成完整的地址,但是每種傳輸協議只能定義一個baseAddress。HTTP的baseAddress同時是service 對外發布服務說明頁面的URL-->
? ? ? ? ? ? <add baseAddress="http://address" />
? ? ? ? ? </baseAddresses>
? ? ? ? ? <timeouts></timeouts>
? ? ? ? </host>
? ? ? ? <!-- 每個服務可以有多個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匹配
? ? ? ? ? ? ? ? ? ?behaviorConfiguration -指定這個endpoint的behavior,指向<behaviors>下的同樣配置名稱的<endpointBehaviors>
? ? ? ? ? ? ? ? name - Endpoint的名稱,可選屬性,每個Contract都可以有多個Endpoint,但是每個Contract對應的
? ? ? ? ? ? ? ? ? ? ? ?多個Endpoint名必須是唯一的-->
? ? ? ? <endpoint address="URI" binding="basicHttpBinding" contract="Contract全限定名" bindingConfiguration="binding名" behaviorConfiguration="String" name="">
? ? ? ? ? <!-- 用戶定義的xml元素集合,一般用作SOAP的header內容-->
? ? ? ? ? <headers>
? ? ? ? ? ? <!-- 任何xml內容-->
? ? ? ? ? </headers>
? ? ? ? </endpoint>
? ? ? </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>元素下<endpoint>的behaviorConfiguration屬性指向這個name-->
? ? ? ? <behavior name="此Behavior名稱">
? ? ? ? ? <!-- 指定service元數據發布和相關信息
? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? httpGetEnabled - bool類型的值,表示是否允許通過HTTP的get方法獲取sevice的WSDL元數據
? ? ? ? ? ? ? ? ? ? httpGetUrl -如果httpGetEnabled為true,這個屬性指示使用哪個URL地址發布服務的WSDL,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?如果這個屬性沒有設置,則使用服務的HTTP類型的baseAddress后面加上?WSDL-->
? ? ? ? ? <serviceMetadata httpGetEnabled="true" httpGetUrl="http://URI:port/address" />
? ? ? ? ? <!--指定驗證服務端的憑據-->
? ? ? ? ? <serviceCredentials>
? ? ? ? ? ? <!--指定服務端的證書
? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? storeName -證書的存儲區,可能值為:AddressBook,AuthRoot,CertificateAuthority
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Disallowed,My,Root,TrustedPeople,TrustedPublisher
? ? ? ? ? ? ? ? ? ? ? ? storeLocation -證書存儲位置,可能值為:CurrentUser,LocalMachine
? ? ? ? ? ? ? ? ? ? ? ? ? ? x509FindType -查找證書的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName......
? ? ? ? ? ? ? ? ? ? ? ? ? ? findValue -對應查找方式的要查找證書的值 ? ? ? ? ? ? ? ?-->
? ? ? ? ? ? <serviceCertificate storeName="存儲區" storeLocation="存儲位置" x509FindType="FindBySubjectName" findValue="server1" />
? ? ? ? ? </serviceCredentials>
? ? ? ? </behavior>
? ? ? </serviceBehaviors>
? ? ? <!-- 定義Endpiont的行為-->
? ? ? <endpointBehaviors>
? ? ? ? <!-- 一個或多個系統提供的或定制的behavior元素
? ? ? ? ? ? ? ?屬性說明:
? ? ? ? ? ? ? ? name -一個behavior唯一標識,<client>元素下<endpoint>的behaviorConfiguration屬性指向這個name-->
? ? ? ? <behavior name="此Behavior名稱">
? ? ? ? ? <!--指定客戶端的憑據-->
? ? ? ? ? <clientCredentials>
? ? ? ? ? ? <!--指定客戶端的證書
? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? storeName -證書的存儲區,可能值為:AddressBook,AuthRoot,CertificateAuthority
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Disallowed,My,Root,TrustedPeople,TrustedPublisher
? ? ? ? ? ? ? ? ? ? ? ? storeLocation -證書存儲位置,可能值為:CurrentUser,LocalMachine
? ? ? ? ? ? ? ? ? ? ? ? ? ? x509FindType -查找證書的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName......
? ? ? ? ? ? ? ? ? ? ? ? ? ? findValue -對應查找方式的要查找證書的值 ? ? ? ? ? ? ? ?-->
? ? ? ? ? ? <clientCertificate storeName="存儲區" storeLocation="存儲位置" x509FindType="FindBySubjectName" findValue="Client1" />
? ? ? ? ? ? <serviceCertificate>
? ? ? ? ? ? ? <authentication certificateValidationMode="None" />
? ? ? ? ? ? </serviceCertificate>
? ? ? ? ? </clientCredentials>
? ? ? ? </behavior>
? ? ? </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
? ? ? ? ? ? ? behaviorConfiguration -指定這個endpoint的behavior,指向<behaviors>下的同樣配置名稱的<endpointBehaviors>-->
? ? ? <endpoint address="URI" binding="basicHttpBinding" bindingConfiguration="binding名" behaviorConfiguration="String" contract="Contract全限定名" name="endpoint配置名" >
? ? ? ? <!-- 用于客戶端驗證服務端身份,可選以下一種方式驗證服務端-->
? ? ? ? <identity>
? ? ? ? ? <userPrincipalName></userPrincipalName>
? ? ? ? ? <servicePrincipalName></servicePrincipalName>
? ? ? ? ? <!--如果客戶端驗證是windows,這里指定DNS名;如果是Certificate,這里指定證書subject name-->
? ? ? ? ? <dns></dns>
? ? ? ? ? <rsa></rsa>
? ? ? ? ? <!--指定服務端證書的公鑰
? ? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? ? ?encodedValue -服務端證書的公鑰的base64編碼,用于加密用戶名和密碼-->
? ? ? ? ? <certificate encodedValue=""></certificate>
? ? ? ? ? <!-- 用戶指定在客戶端證書存儲區內的服務端證書
? ? ? ? ? ? ? ? ? ? ? ? 屬性說明:
? ? ? ? ? ? ? ? ? ? ? ? storeName -證書的存儲區,可能值為:AddressBook,AuthRoot,CertificateAuthority
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Disallowed,My,Root,TrustedPeople,TrustedPublisher
? ? ? ? ? ? ? ? ? ? ? ? storeLocation -證書存儲位置,可能值為:CurrentUser,LocalMachine
? ? ? ? ? ? ? ? ? ? ? ? ? ? x509FindType -查找證書的方式,可能的值:FindBySubjectName,FindByThumbPrint,FindByIssuerName......
? ? ? ? ? ? ? ? ? ? ? ? ? ? findValue -對應查找方式的要查找證書的值 ? ? ? ? ? ? ? ?-->
? ? ? ? ? <certificateReference storeName="存儲區" storeLocation="存儲位置" x509FindType="FindBySubjectName" findValue="Client1" />
? ? ? ? </identity>
? ? ? </endpoint>
? ? </client>
? </system.ServiceModel>
</configuration>
總結
- 上一篇: sql日期查询问题
- 下一篇: C# Datagridview完整攻略