2

I'm just starting out with WCF web services, and I'm having a really hard time finding a very simple tutorial, so I thought I'd ask some questions here.

Here's my setup: I have a WPF desktop application that needs to send data over the internet to a web service on our server.

The way I see it, I have at least these four options:

  1. I can do New Website --> WCF Service
  2. or New Project --> WCF Service Application
  3. or I can add a project to my existing WPF desktop app solution for a WCF Service Application
  4. or I can add a project for a WCF Service Library

Can anyone tell me which is the best choice, and then maybe point to a tutorial to help me get started along that route?

3 Answers 3

2

This is all rather subjective of course

  1. WCF Service Website - I avoid anything to do with New Websites. They're nasty horrible things, which don't build the way I want and assume everything in a directory belongs to them. There were masses of complaints when MS took away web applications, and they eventually were returned. I'd always recommend avoiding.
  2. A WCF service application creates a new solution with a WCF service application in it. (see 3.)
  3. This adds a new service application. This contains everything a WCF service needs to run, on a web including a sample SVC file, a sample contract and some preplumbed configuration settings.
  4. This is the bare bones, with no hosting application at all, just a sample config, a sample contract and a sample implementation. If you run this it hosts it in the WCF test server.

If you already have a solution for your desktop application then I'd suggest you add a new WCF service application project to your solution and keep everything in one place. You can also set Visual Studio to run both applications when debugging, so you can actually check everything works together.

If you were writing a separate set of services, to be used by multiple client programmes which all exist in separate solutions I'd have option 2, and then option 4 when you want more flexibility such as hosting the services in a command line application or windows service.

2
  • Ok, I'm really not clear on why I shouldn't use a web site for web services. It seems like the natural fit. I hesitate to create a new project inside my desktop solution because I will eventually be deploying the application to a computer on-board a ship. It will need to communicate via the Internet to a shore-side server where the web service will be hosted. If I put both client and server-side parts into the same solution, I worry that this will complicate deployment.
    – Klay
    Jul 23, 2009 at 15:22
  • Why would it complicate deployment? Surely you're creating an installer for your WPF client anyway, and that only includes the WPF bits. It's natural to keep all the bits for a complete solution together in one solution. Just because they're together doesn't mean they all get mixed up in one directory. Projects compile into their own directories
    – blowdart
    Jul 23, 2009 at 18:08
0

Here is a good (if not a bit dated) "hello world" WCF tutorial: Windows Communication Foundation (Indigo) Hello World Tutorial:

This first tutorial will look at installing WCF (as part of the .net Framework 3.0), including the Visual Studio 2005 integration, and producing a first simple "Hello World" service to demonstrate some of the key concepts of the platform. The samples are all in C#, but I can spin off VB.Net equivalents if there is sufficient interest. Also, previous versions of this series (that targeted various pre-release versions of WCF) used Notepad and the command line to build and compile WCF services. This latest version makes use of Visual Studio because, especially with the RTM release, I suspect that is what most readers will be using. If you're interested in crafting your services by hand to explore the underpinnings of WCF more closely (or to obtain the asynchronous implementation, as you will see further down), let me know and I'll update the earlier samples. So, with that all covered, let's get to installing and using WCF!

4
  • Thanks for the quick reply! I'm worried that this tutorial uses none of the built-in WCF project templates--specifically that significant changes have occurred since .NET 3.0.
    – Klay
    Jul 23, 2009 at 14:49
  • Don't worry about the templates - the nice thing about WCF is that templates are largely unnecessary. I would recommend setting up without a template as this will allow you to see how things work under the covers - you will be suprised how little a template offers! Jul 23, 2009 at 14:53
  • Seriously, no. Yes, it will work without the templates, but when he comes back here asking questions without the templates, people will say "huh?" Jul 23, 2009 at 15:12
  • So if I should not use the new web site wcf service template, which template should I use? Please see my comment above to understand my reticence to add the wcf service project inside my desktop app solution.
    – Klay
    Jul 23, 2009 at 15:24
0

I managed to finally find a very clear start-to-finish tutorial on propping up a WCF web service here. I set everything up according to the tutorial, and so far it works very well. Hopefully there won't be any problems later with deployment or maintenance--guess we'll see.

Incidentally, it uses the New Web Site --> WCF Service template which other posters here have explicitly said not to use. I don't mean to sound contentious, but it seems to work me.

1
  • I don't think anyone is saying that the web site compilation model doesn't work, but rather that it is a bit unwieldly. In fact, it seems like the web site model was created as a "starter" model for new asp.net developers. Depending on the nature of your service application, you will likely run into challenges with the web site model as your application architecture becomes more sophisticated. I believe Visual Studio will allow you to convert a web site to a web application, with very little work. I would join the others in suggesting that you do that conversion at some point; your decision.
    – mtazva
    Jul 31, 2009 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.