码迷,mamicode.com
首页 > 其他好文 > 详细

wcf第1步

时间:2016-06-17 16:46:43      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

添加System.ServiceModel 引用

 

class Program
{
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(GreetService), new Uri("http://localhost:20000"));
host.AddServiceEndpoint(typeof (IGreetService), new BasicHttpBinding(), "GreetService");
host.Description.Behaviors.Add(new ServiceMetadataBehavior(){HttpGetEnabled = true});
 
host.Open();
Console.WriteLine("服务已开启");
Console.Read();
}
}

[ServiceContract]
public interface IGreetService
{
[OperationContract]
string Greet(string name);

}

public class GreetService : IGreetService
{

public string Greet(string name)
{
Console.WriteLine(("Hello:"+name));
return "Welcome:" + name;
}
}

 

wcf第1步

标签:

原文地址:http://www.cnblogs.com/zhshlimi/p/5594240.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!