在linux上托管WCF服务 [英] Hosting WCF service on linux
本文介绍了在linux上托管WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法在Linux上托管WCF服务。
我读了关于葡萄酒,但我没有看到任何托管WCF服务的例子。
Is there Any way of hosting WCF service on Linux. I read about wine but i didn't see any example of hosting WCF service with it.
PS:我试过mono和mod_mono但没有。
P.S : I have tried mono and mod_mono but to no avail.
推荐答案
您可以在独立的控制台应用程序中托管它:
You can host it in a stand-alone console application like so:
using System;
using System.ServiceModel;
using Service;
namespace Host
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("WCF Host!");
var binding = new BasicHttpBinding ();
var address = new Uri ("http://localhost:8080");
var host = new ServiceHost (typeof(GreeterWcfService));
host.AddServiceEndpoint (
typeof(IGreeterWcfService), binding, address);
host.Open ();
Console.WriteLine ("Type [CR] to stop...");
Console.ReadLine ();
host.Close ();
}
}
}
其中 GreeterWcfService
是WCF服务类本身, IGreeterWcfService
是服务合同。
Where GreeterWcfService
is the WCF service class itself and IGreeterWcfService
is the service contract.
GitHub上的完整工作示例解决方案 - 为服务,托管和客户端提供单独的项目。看看吧。
Full working example solution in GitHub - with separate projects for the service, the hosting and a client. Check it out.
这篇关于在linux上托管WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文