首页 > 其他 > 详细

wcf第1步

时间:2016-06-17 16:46:42      阅读:189      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!