问题
I would like to create a RESTful web service that I can deploy on an IIS 7 web server. I was going through some tutorials and came across the WebServiceHost
class.
From what I understand, I should be able to use this and have it on IIS with no configuration required.
Is that true? If not, what is the simplest deployment option for this type of Web Service. I am hoping there are options where I don't need to do too much with IIS 7.
回答1:
Code snippets you see with WebServiceHost pertain to hosting your service in a Windows service that you create or in a console application.
You can directly host it in IIS. Not extra code required. You will however have to add additional configuration settings in the web.config.
See this article ... http://msdn.microsoft.com/en-us/library/bb412178.aspx
Relevant snippet from the above article ...
You can also host such a service within IIS. To do this, specify the WebServiceHostFactory class in a .svc file as the following code demonstrates.
<%ServiceHost
language=c#
Debug="true"
Service="Microsoft.Samples.Service"
Factory=System.ServiceModel.Activation.WebServiceHostFactory%>
回答2:
Check out WCF Data Services.
http://msdn.microsoft.com/en-us/data/bb931106
来源:https://stackoverflow.com/questions/5747751/how-to-host-a-restful-wcf-web-service