国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
WCF元數(shù)據(jù)交換

元數(shù)據(jù)的配置、交換

WCF服務(wù)元數(shù)據(jù)是WCF服務(wù)的核心部分服務(wù)地址(Address)、綁定(通信協(xié)議Binding)、契約(服務(wù)、操作、數(shù)據(jù)Contract)的原始描述信息。服務(wù)所公開的元數(shù)據(jù)包括 XSD(文檔中出現(xiàn)的元素、文檔中出現(xiàn)的屬性、子元素、子元素的數(shù)量、子元素的順序、元素是否為空、元素和屬性的數(shù)據(jù)類型、元素或?qū)傩缘哪J(rèn)和固定值)和 WSDL 文檔(用于描述服務(wù)的方法、參數(shù)、參數(shù)個數(shù)、順序、返回值、返回值的類型等方法的相關(guān)信息)。.Disco文檔(描述服務(wù)的協(xié)議、地址、命名空間等信息)。

元數(shù)據(jù)的信息除了包括服務(wù)、數(shù)據(jù)、操作等契約的相關(guān)的信息外,還有其他的如事物、可靠性、錯誤處理等相關(guān)的信息。

兩種發(fā)布元數(shù)據(jù)的方式使用了兩種不同的標(biāo)準(zhǔn)網(wǎng)絡(luò)傳輸協(xié)議,前者為HTTP/GET請求,后者為WS-MetadataExchange(MEXWCF支持的基本綁定HTTP、HTTPS、TCP、IPC等綁定協(xié)議)要了解這兩種協(xié)議的區(qū)別,得先了解一下什么事WS-MEX
 

他們的區(qū)別可以體現(xiàn)在WS-*上,在使用WS-MEX以后,我們可以使用其他WS-*相關(guān)的標(biāo)準(zhǔn)來展示端點的元數(shù)據(jù),比如WS-Secyrity。WS-MEX默認(rèn)是使用httpBinding

 

1.HTTP GET方式

 

 
 
配置方式:

 

<behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceApp.WCFServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8001/" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

 

在設(shè)置httpGetEnabled="true"以后便會在我們的服務(wù)幫助頁面( 幫助頁面可以設(shè)置行為的<serviceDebug httpHelpPageEnabled="false"/>關(guān)閉)的SvcUtil.exe指令之后帶一個?WSDL后綴的活動鏈接,點擊該鏈接,便會進(jìn)入該服務(wù)的WSDL文檔中。

httpGetUrl 屬性, 如果httpGetEnabledtrue,這個屬性指示使用哪個URL地址發(fā)布服務(wù)的WSDL。

要發(fā)布Metadata,需要對外提供一個Http的地址,由HttpGetUrl 屬性指定。

如果HttpGetUrl指定了絕對地址,那么對外發(fā)布Metadata的地址就為:HttpGetUrl 后加?wsdl。

如果HttpGetUrl指定了相對地址,那么對外發(fā)布Metadata的地址就為: ServiceHostbaseAddress + HttpGetUrl 后加?wsdl

如果沒有設(shè)置HttpGetUrl,那么Metadata的地址就是ServiceHostbaseAddress后加?wsdl

不管HttpGetUrl屬性怎么設(shè)置,ServiceHostbaseAddress總是作為這個ServiceHost提供服務(wù)的描述頁面的URL。
 

<service behaviorConfiguration="NewBehavior" name="Messaging.Host.Service">

<endpoint  address="" binding="basicHttpBinding"   

      contract="Messaging.Host.IService" />

<host

<baseAddresses>

        <add baseAddress="http://localhost:8080/WCFService/Service" />

       </baseAddresses>

     </host>

</service>


那么,他的WSDL就是http://localhost:8080/WCFService/Service?WSDL

代碼方式:

ServiceMetadataBehavior metadataBehavior;//定義服務(wù)行為變量,
 metadataBehavior 

= host.Description.Behaviors.Find<ServiceMetadataBehavior>();
 //獲取宿主的行為列表
 if (metadataBehavior == null)//如果沒有服務(wù)原數(shù)據(jù)交換的行為,實例化添加服務(wù)原數(shù)據(jù)交換行為
 {
      metadataBehavior = new ServiceMetadataBehavior();
      Uri httpAddress = new Uri("http://localhost:8001/");
      metadataBehavior.HttpGetUrl =httpAddress;
      metadataBehavior.HttpGetEnabled = true;//設(shè)置HTTP方式
      host.Description.Behaviors.Add(metadataBehavior);
}

首先是獲得服務(wù)行為的列表信息,如果沒有設(shè)置,我們就進(jìn)行實例化服務(wù)原數(shù)據(jù)交換行為,并設(shè)置http方式可用。 host.Description.Behaviors.Add(metadataBehavior);添加宿主服務(wù)的行為。

2.WS-MEX

配置方式:

這里配置了3種方式的元數(shù)據(jù)交換終結(jié)點,分別是HTTP、TCP、IPC方式。

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
        <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8001/"/>
            <add baseAddress="net.tcp://localhost:8002/"/>
            <add baseAddress="net.pipe://localhost/"/>
          </baseAddresses>
        </host>

元數(shù)據(jù)的地址就是對應(yīng)的baseAddress/mes。比如http://localhost:8001/mex

代碼方式:
 

//2編程方式實現(xiàn)ws*原數(shù)據(jù)交,聲明三個綁定節(jié)點類
 BindingElement tcpBindingElement = new TcpTransportBindingElement();
BindingElement httpBindingElement = new HttpsTransportBindingElement();
 BindingElement pipeBindingElement = new NamedPipeTransportBindingElement();
 //實例化通用綁定類的實例
 Binding tcpBinding = new CustomBinding(tcpBindingElement);
 Binding httpBinding = new CustomBinding(httpBindingElement);
 Binding pipeBinding = new CustomBinding(pipeBindingElement);
 
 Uri tcpBaseAddress = new Uri("net.tcp://localhost:9001/");
 Uri httpBaseAddress = new Uri("http://localhost:9002/");
  Uri pipeBaseAddress = new Uri("net.pipe://localhost/");
                host.AddServiceEndpoint(typeof(WCFService.IWCFService), new NetTcpBinding(), tcpBaseAddress);
                host.AddServiceEndpoint(typeof(WCFService.IWCFService), new WSHttpBinding(), httpBaseAddress);
                host.AddServiceEndpoint(typeof(WCFService.IWCFService), new NetNamedPipeBinding(), pipeBaseAddress);
                
                //ServiceMetadataBehavior metadataBehavior;//定義服務(wù)行為變量,
                metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
                //獲取宿主的行為列表
                if (metadataBehavior == null)//如果沒有服務(wù)原數(shù)據(jù)交換的行為,實例化添加服務(wù)原數(shù)據(jù)交換行為
                {
                    metadataBehavior = new ServiceMetadataBehavior();

                    host.Description.Behaviors.Add(metadataBehavior);
                }
                //如果沒有可用的mex節(jié)點,可以使用一下代碼判斷,添加mex節(jié)點
                
                host.AddServiceEndpoint(typeof(IMetadataExchange), tcpBinding, "mex");
                host.AddServiceEndpoint(typeof(IMetadataExchange), httpBinding, "mex");
                host.AddServiceEndpoint(typeof(IMetadataExchange), pipeBinding, "mex");

 

 

參考:

http://www.cnblogs.com/frank_xl/archive/2009/03/30/1421862.html

http://www.cnblogs.com/chnking/archive/2008/01/21/1047754.html

http://www.cnblogs.com/chnking/archive/2008/01/22/1049345.html

http://www.cnblogs.com/jillzhang/archive/2008/01/30/1059169.html

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
[老老實實學(xué)WCF] 第六篇 元數(shù)據(jù)交換
如何將一個服務(wù)發(fā)布成WSDL[基于HTTP-GET的實現(xiàn)]
使用nginx搭建高可用,高并發(fā)的wcf集群
WCF后傳系列(2):深入WCF尋址Part 2—自定義尋址報頭
WCF: Host、Client、MetadataExchage
[Error] WCF: SOAP security negotiation
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服