Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting WCF service on linux

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.

P.S : I have tried mono and mod_mono but to no avail.

like image 760
satishsingh2230 Avatar asked Jul 10 '14 05:07

satishsingh2230


People also ask

Does WCF work on Linux?

NET cross-platform world where WCF code can now run on Linux servers as well as on Windows.

Where can I host WCF service?

WCF services can be hosted in any managed application. This is the most flexible option because it requires the least infrastructure to deploy. You embed the code for the service inside the managed application code and then create and open an instance of the ServiceHost to make the service available.

How do I run a WCF service?

Press Ctrl + F5 to run the service. Open WCF Test Client. To open WCF Test Client, open Developer Command Prompt for Visual Studio and execute WcfTestClient.exe. Select Add Service from the File menu.

Is WCF still supported?

NET Framework technologies, your WCF applications will continue to work for a long time. In fact, WCF will likely work for the next two decades thanks to . NET Framework being considered part of the windows operating system.


2 Answers

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 [Enter] to stop...");
            Console.ReadLine ();
            host.Close ();
        }
    }
}

Where GreeterWcfService is the WCF service class itself and IGreeterWcfService is the service contract.

Full working example solution in GitHub - with separate projects for the service, the hosting and a client. Check it out.

like image 111
shturm Avatar answered Oct 24 '22 05:10

shturm


Its possible but you should refer to this link for understanding current state and known issues - http://www.mono-project.com/docs/web/wcf/. It's limited now. For eg. if you wish to use WSHttpBinding its not supported currently.

like image 20
thinkster Avatar answered Oct 24 '22 04:10

thinkster