ASP.Net Web API vs WCF - Can the Web API be used to provide REST-based communication to a singleton WCF service?

StackOverflow https://stackoverflow.com/questions/9381016

Question

I have an existing set of singleton WCF services. They are long-running processes that do a lot of work on an ongoing basis and expose themselves with WCF service contracts for communication with other processes.

When the WCF Web API was being developed I was excited because it was looking like I'd finally be able to do away with all of the annoying contract stuff and simply provide a platform-agnostic REST API for each service and have the processes communicate via HTTP requests and JSON responses.

Now it looks like the Web API has become an IIS-hosted ASP.Net feature, leaving me trying to figure out if I'm just missing something or if my WCF services will no longer have the opportunity to provide a REST interface.

If the Web API is no longer really targeted at my scenario, what has the ASP.Net team envisioned with respect to non-terminating singleton processes that wish to provide an HTTP/JSON-based API to other consuming processes?

Was it helpful?

Solution

You do not have to host ASP.NET Web API services in IIS. There is an option called "Self Hosting" that will allow you to host your API services in another process (such as a Windows Service) if you would like. I imagine that your current architecture would work just fine as a self-hosted app.

OTHER TIPS

You can self-host using ServiceHost as in this MSDN example. See related SO post. Essentially - IIS is not a requirement for WCF hosting.

If you are using webHttpBinding - you just need to create the WebServiceHost which extends from ServiceHost to support REST.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top