新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
WCF服務(wù)啟動(dòng)特殊方法分享
對(duì)于WCF服務(wù)啟動(dòng)的方法,我們可以通過(guò)多種方式來(lái)實(shí)現(xiàn)。在這里我們將會(huì)通過(guò)一種特殊的方法來(lái)實(shí)現(xiàn)WCF服務(wù)啟動(dòng)。大家首先可以通過(guò)一段代碼示例來(lái)詳細(xì)分析一下這一服務(wù)的啟動(dòng)方法,以此加深這方面的印象。

專注于為中小企業(yè)提供網(wǎng)站制作、成都網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)隴縣免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千多家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
WCF服務(wù)啟動(dòng)代碼示例:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ServiceModel;
- using System.ServiceModel.Description;
- namespace WCF1
- {
- [ServiceContract(Name = "MyService", Namespace =
"http://www.huisoftware.com")]- public class MyService
- {
- [OperationContract]
- public string MyMethod(string str)
- {
- return str + "Server Hello World";
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- using (ServiceHost host = new ServiceHost(typeof(MyService)))
- {
- host.AddServiceEndpoint(typeof(MyService), new WSHttpBinding(),
"http://127.0.0.1:8080/MyService");- if (host.Description.Behaviors.Find
() == null) - {
- ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
- behavior.HttpGetEnabled = true;
- behavior.HttpGetUrl = new Uri("http://127.0.0.1:8080
/MyService/metadata");- host.Description.Behaviors.Add(behavior);
- }
- host.Opened += delegate
- {
- Console.WriteLine("WCF服務(wù)已經(jīng)啟動(dòng)");
- };
- host.Open();
- Console.Read();
- }
- }
- }
- }
WCF服務(wù)啟動(dòng)的相關(guān)代碼就為大家介紹到這里。
【編輯推薦】
- WCF依賴屬性具體概念詳解
- WCF跨域具體問(wèn)題解析
- WCF消息交換應(yīng)用方式技巧分享
- WCF會(huì)話狀態(tài)功能特點(diǎn)解析
- WCF綁定元素具體應(yīng)用知識(shí)介紹
當(dāng)前標(biāo)題:WCF服務(wù)啟動(dòng)特殊方法分享
標(biāo)題路徑:http://fisionsoft.com.cn/article/coecccg.html


咨詢
建站咨詢
