How to Host a Restful WCF Web Service

隐身守侯 提交于 2020-01-13 13:12:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!