欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

HostingWCFService-創(chuàng)新互聯(lián)

There are some ways to hosting WCF service as below:

創(chuàng)新互聯(lián)是一家專業(yè)的成都網(wǎng)站建設(shè)公司,我們專注網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷、企業(yè)網(wǎng)站建設(shè),買鏈接廣告投放為企業(yè)客戶提供一站式建站解決方案,能帶給客戶新的互聯(lián)網(wǎng)理念。從網(wǎng)站結(jié)構(gòu)的規(guī)劃UI設(shè)計到用戶體驗提高,創(chuàng)新互聯(lián)力求做到盡善盡美。

1. IIS; 2. Console App; 3. Window Service

Using Console Application to host WCF service:

Step 1:

 

Step 2: Add a Class Library project : 'Contract'

Step 3: Add a Interface : 'IHelloWorld'

using System.ServiceModel;

namespace Contract
{
    [ServiceContract(Name= "HelloWorldService")]
public interface IHelloWorld
    {
        [OperationContract]
string SayHello();
    }
}

Step 4: Add a Class : 'HelloWorld'

namespace Contract
{
public class HelloWorld : IHelloWorld
    {
public string SayHello()
        {
return "Hello World. I'm WCF Service.";
        }
    }
}

Step 5: Add a Console Application : 'Host'

Step 6:
Use WCF Service Configuration Editor to generate the server config.

<?xml version="1.0" encoding="utf-8"?><configuration>  <system.serviceModel>   <behaviors> <serviceBehaviors>  <behaviorname="HelloWorldBehavior">   <serviceMetadatahttpGetEnabled="true" />  </behavior> </serviceBehaviors>   </behaviors>   <services> <servicebehaviorConfiguration="HelloWorldBehavior" name="Contract.HelloWorld">  <endpointaddress="http://localhost:9999/HelloWorldService" binding="basicHttpBinding"
                    bindingConfiguration="" contract="Contract.IHelloWorld" />  <host>   <baseAddresses> <addbaseAddress="http://localhost:9999/HelloWorldService" />   </baseAddresses>  </host> </service>   </services>  </system.serviceModel></configuration>

Step 7:
Set up server host

using System;
using System.ServiceModel;
using Contract;

namespace Host
{
class Program
    {
static void Main(string[] args)
        {
using (var host = new ServiceHost(typeof(HelloWorld)))
            {
                host.Opened+= delegate
                                   {
                                       Console.WriteLine("CalculaorService已經(jīng)啟動,按任意鍵終止服務(wù)!");
                                   };
                host.Open();  
                Console.Read();
            }
        }
    }
}

本文名稱:HostingWCFService-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://www.chinadenli.net/article8/djohip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)網(wǎng)站營銷全網(wǎng)營銷推廣網(wǎng)站策劃企業(yè)建站域名注冊

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計