自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

WCF宿主模式主要概念總結(jié)

開發(fā) 開發(fā)工具
WCF宿主模式的類型繁多,在實(shí)際應(yīng)用中,大家可以根據(jù)自己不同的需要來選擇一個適合的類型完成相關(guān)功能的開發(fā)。

WCF開發(fā)工具的應(yīng)用在一定程度上給開發(fā)人員帶來了非常大的好處。在這里我們將會針對WCF宿主模式的相關(guān)概念進(jìn)行一個詳細(xì)的介紹。WCF宿主模式比較靈活,我們可以依據(jù)服務(wù)的使用目的從多種宿主中選擇一個最適合的。#t#

可用的WCF宿主模式包括:

"Self-Hosting" in a Managed Application: 也就是 Console Application 或者 WinForm Application。我們在前面的章節(jié)都是使用這種模式進(jìn)行演示。它的好處是簡單、部署方便,但缺乏相關(guān)環(huán)境支持,不適合用于企業(yè)級服務(wù)部署。

Managed Windows Services: 可以隨著操作系統(tǒng)自動啟動,受服務(wù)權(quán)限限制,安全性要比上一種好些。

Internet Information Services (IIS): 和 Web Services 的部署方式類似,由請求消息來激活服務(wù),還可以使用 IIS 提供的 Process recycling、Idle shutdown、Process health monitoring 等功能。缺點(diǎn)是只能使用 Http Binding。

Windows Process Activation Service (WAS): 這個宿主只有 Windows Vista 和 Microsoft Windows Server(Longhorn) 才提供,它是 IIS7 的一部分。這應(yīng)該是所有WCF宿主模式中最適合企業(yè)級部署應(yīng)用的。除了 IIS 所提供的那些功能外,最關(guān)鍵的是它支持幾乎所有的通訊協(xié)議。

"Managed Application" 和 "Windows Services" 部署方式非常類似,本文不再詳述。以下介紹一下 IIS 部署的步驟。

1. 安裝完 VS Extension 后,我們可以創(chuàng)建一個 WCF service 的網(wǎng)站項(xiàng)目。

2. 添加一個 WCF service 新項(xiàng),系統(tǒng)自動會創(chuàng)建 Service.svc、App_Code\Service.cs 等必要文件。

3. 在 Service.cs 文件中完成服務(wù)編碼。

4. 添加 web.config 文件,并在其位置單擊鼠標(biāo)右鍵,打開 "Microsoft Service Configuration Editor" 工具完成服務(wù)配置。

5. 注意添加 serviceMetadata,否則我們使用瀏覽器無法查看,也無法創(chuàng)建客戶端代理。

web.config 演示 (注意配置文件中并沒有提供服務(wù)地址)

 

  1. < ?xml version="1.0"?> 
  2. < configuration xmlns="http://schemas.microsoft.com/
    .NetConfiguration/v2.0"
    > 
  3. < system.serviceModel> 
  4. < services> 
  5. < service behaviorConfiguration="MyServiceTypeBehaviors" 
    name="MyService"> 
  6. < endpoint binding="wsHttpBinding" contract="IMyService"/> 
  7. < /service> 
  8. < /services> 
  9. < behaviors> 
  10. < serviceBehaviors> 
  11. < behavior name="MyServiceTypeBehaviors"> 
  12. < serviceMetadata httpGetEnabled="true"/> 
  13. < serviceDebug includeExceptionDetailInFaults="true"/> 
  14. < /behavior> 
  15. < /serviceBehaviors> 
  16. < /behaviors> 
  17. < /system.serviceModel> 
  18. < system.web> 
  19. < compilation debug="true"> 
  20. < /system.web> 
  21. < /configuration> 

service.svc

 

  1. < %@ ServiceHost Language="C#" Debug="true" Service="MyService" 
    CodeBehind="~/App_Code/service.cs" %> 

以上就是對WCF宿主模式的相關(guān)介紹。

責(zé)任編輯:曹凱 來源: 豆豆網(wǎng)
相關(guān)推薦

2009-12-21 17:05:59

WCF自托管宿主

2010-02-24 17:17:04

WCF宿主環(huán)境

2009-12-21 18:19:19

WCF地址類型

2009-07-31 09:29:05

GWT 2.0

2009-12-21 10:27:52

WCF基本概念

2009-11-06 16:22:35

WCF協(xié)定

2009-11-05 11:23:08

WCF宿主

2010-02-22 16:09:33

WCF宿主

2009-11-06 15:41:25

WCF自托管宿主

2010-02-25 18:04:02

WCF IIS宿主

2010-02-25 18:37:23

WCF自宿主

2009-11-06 15:47:17

WCF Windows

2010-02-23 16:32:29

WCF服務(wù)

2010-02-25 14:26:48

WCF特點(diǎn)

2009-11-05 10:37:58

WCF Address

2010-02-24 12:49:39

WCF枚舉

2012-02-20 14:20:44

JavaPlay Framew

2010-02-22 17:34:39

WCF依賴屬性

2009-12-21 15:33:07

WCF集合元素

2010-03-01 14:50:30

WCF行為類型
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號