简体   繁体   English

如何通过互联网托管WCF Web服务?

[英]How to host WCF web service over the internet?

I work as a C# developer and we have many .NET web services that we use. 我是C#开发人员,我们使用许多.NET Web服务。 I am doing some at home development and want to do something similar. 我正在做一些家庭开发,并且想要做类似的事情。 I have a database (SQL Server 2012) on a home PC running Windows Server 2012 with IIS 8 installed. 我在运行Windows Server 2012且安装了IIS 8的家用PC上有一个数据库(SQL Server 2012)。 I have created a WCF web service in Visual Studio (C#) and it compiles to a .svc file. 我已经在Visual Studio(C#)中创建了WCF Web服务,并将其编译为.svc文件。 This just facilitates data exchange between my SQL Server Database and the application I am writing. 这只是促进了我的SQL Server数据库和正在编写的应用程序之间的数据交换。

I am unfamiliar with how to host the WCF service so that the Windows Form application that I am writing that will be installed on many non-local machines can access it. 我不熟悉如何托管WCF服务,以便我正在编写的Windows Form应用程序可以访问它,该应用程序将安装在许多非本地计算机上。 I figured a WCF service would be the best choice for accessing my database for the WinForm application over the internet. 我认为WCF服务将是通过Internet访问WinForm应用程序数据库的最佳选择。

I also have a domain with a basic Windows package on 1&1.com leftover from a previous project if that helps. 如果有帮助,我还会在1&1.com上有一个域,该域的基本Windows程序包是以前项目中剩余的。

Can anyone give me some steps to get my WCF service hosted so it can be accessed over the internet? 谁能给我一些步骤来托管我的WCF服务,以便可以通过Internet进行访问? Please ask if I forgot to list any needed information. 请询问我是否忘记列出任何需要的信息。

Two common ways are to host your WCF service from IIS, or to self host it yourself from within a simple wrapper program that acts as a TCP server. 两种常见的方法是从IIS托管WCF服务,或者从充当TCP服务器的简单包装程序中自己托管自己的WCF服务。

See http://msdn.microsoft.com/en-us/library/ee939285.aspx 请参阅http://msdn.microsoft.com/en-us/library/ee939285.aspx

The simplest way is to setup IIS and just publish your services like you would a web application; 最简单的方法是设置IIS,就像发布Web应用程序一样发布服务。 your service will exposed over http/https. 您的服务将通过http / https公开。 Use an appropriate binding like wsHttpBinding or BasicHttpBinding depending on your security needs. 根据您的安全需求,使用诸如wsHttpBinding或BasicHttpBinding之类的适当绑定。 Read up to understand the different bindings and what each does and does not support. 阅读以了解不同的绑定以及每个绑定支持和不支持的功能。

In order to host WCF via IIS, at least on Windows Server 2003 and 2008, make sure you follow the install steps, such as adding .NET 3.5.1 / WCF options on older platforms. 为了至少在Windows Server 2003和2008上通过IIS承载WCF,请确保遵循安装步骤,例如在较旧的平台上添加.NET 3.5.1 / WCF选项。 I believe Server 2012 includes it within .NET 4 framework, but I haven't yet done it on 2012. 我相信Server 2012会将它包含在.NET 4框架中,但是我还没有在2012年完成它。

Google "WCF hosting IIS" for steps / setup guides. Google的“ WCF托管IIS”以获取步骤/设置指南。

There are also hosting providers that specifically provide WCF hosting solutions, though I'm pretty sure your current provider, since it supports IIS, should do fine. 还有一些托管提供程序专门提供WCF托管解决方案,尽管我很确定您当前的提供程序(因为它支持IIS)应该可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM