如何托管Restful WCF Web服务 [英] How to Host a Restful WCF Web Service

查看:190
本文介绍了如何托管Restful WCF Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个可以在IIS 7 Web服务器上部署的RESTful Web服务。我正在阅读一些教程并遇到了 WebServiceHost 类。

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.

根据我的理解,我应该能够使用它并在IIS上使用它,无需配置。

From what I understand, I should be able to use this and have it on IIS with no configuration required.

这是真的吗?如果没有,这种类型的Web服务的最简单部署选项是什么。我希望有一些选项,我不需要对IIS 7做太多。

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.

推荐答案

你看到的代码片段WebServiceHost适用于在您创建的Windows服务或控制台应用程序中托管您的服务。

Code snippets you see with WebServiceHost pertain to hosting your service in a Windows service that you create or in a console application.

您可以直接在IIS中托管它。不需要额外的代码。但是,您必须在web.config中添加其他配置设置。

You can directly host it in IIS. Not extra code required. You will however have to add additional configuration settings in the web.config.

请参阅此文章... http://msdn.microsoft.com/en-us/library/bb412178.aspx

See this article ... http://msdn.microsoft.com/en-us/library/bb412178.aspx

上述文章中的相关摘要...

Relevant snippet from the above article ...

您还可以在IIS中托管此类服务。为此,请在.svc文件中指定WebServiceHostFactory类,如以下代码所示。

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%>

这篇关于如何托管Restful WCF Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆