简体   繁体   中英

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. 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. I have created a WCF web service in Visual Studio (C#) and it compiles to a .svc file. This just facilitates data exchange between my SQL Server Database and the application I am writing.

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. I figured a WCF service would be the best choice for accessing my database for the WinForm application over the internet.

I also have a domain with a basic Windows package on 1&1.com leftover from a previous project if that helps.

Can anyone give me some steps to get my WCF service hosted so it can be accessed over the 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.

See 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; your service will exposed over http/https. Use an appropriate binding like wsHttpBinding or BasicHttpBinding depending on your security needs. 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. I believe Server 2012 includes it within .NET 4 framework, but I haven't yet done it on 2012.

Google "WCF hosting IIS" for steps / setup guides.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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