標籤:blog http os io ar strong 檔案 div cti
在.NET 3.5中,我們需要這樣做:
1. 添加一個HelloService.svc檔案,添加ServiceHost標記,在Service中添加WCF服務實現的名稱,比如:
<%@ ServiceHost Language="C#" Debug="false" Service="CNBlogs.Service.Impl.HelloService"%>
2. 在web.config/system.serviceModel/bindings/basicHttpBinding中添加一個binding。
3. 在web.config/system.serviceModel/behaviors/serviceBehaviors中添加一個behavior。
4. 在web.config/system.serviceModel/services中添加一個service,並且:
a) 設定behaviorConfiguration屬性。
b) 設定name屬性。
5. 在service下添加一個endpoint,並且:
a) 設定binding屬性。
b) 設定name屬性。
c) 設定contract屬性。
在.NET 4中,我們只要這樣做:
在web.config/system.serviceModel/serviceHostingEnvironment/serviceActivations中增加下面兩個屬性即可:
<add relativeAddress="HelloService.svc" service="CNBlogs.Service.Impl.HelloService"/>
這樣配置後,就可以正常調用WCF服務。
如果需要通過SvcUtil.exe產生用戶端代理,只需在serviceBehaviors中添加:
<behavior>
<serviceMetadata httpGetEnabled="true"/>
</behavior> 轉載出處:http://www.cnblogs.com/dudu/archive/2011/01/18/1938490.html
在.NET 4中用IIS部署WCF就這麼簡單