登陆 | 注册
你现在的位置:我的论坛 >> 微软新技术 >> hello wcf
hello wcf
大狗熊
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;

namespace WCFServer
{
    [ServiceContract]
    
public interface IBBSService
    {
        [OperationContract]
        
string FindName();
    }

    
public class BBSService : IBBSService
    {
        
public string FindName()
        {
            
return "hello";
        }
    }

    
class Program
    {
        
static void Main(string[] args)
        {
            ServiceHost host 
= new ServiceHost(typeof(BBSService), new Uri("http://localhost:8000/"));
            host.AddServiceEndpoint(
typeof(IBBSService), new BasicHttpBinding(), "BBSService");
            ServiceMetadataBehavior behavior 
= new ServiceMetadataBehavior();
            behavior.HttpGetEnabled 
= true;
            host.Description.Behaviors.Add(behavior);
            host.Open();
            Console.ReadLine();
            host.Close();
        }
    }
}
楼主 创建:08-04-20 00:12:32 更新:08-04-20 00:12:32
发表回复


Copyright (C) 2004-2008, All Rights Reserved