Wednesday, April 28, 2010

Creating a WCF Web Service with VS2010 Express

Last night while I was reading up on OPC-XML the interwebs took me on a merry trail of SOAP, XML-RPC and the like that ended with WCF Web Services. I found a very good tutorial on WCF Services at but this was for Visual Studio 2005. I only have express versions of Visual Studio 2010 so there were some things that needed to be done differently. In the interests of posterity here is how I wrote a very simple WCF web service and a WPF client that accesses it using only Visual Web Developer 2010 Express and Visual C# 2010 Express.

Configure the Development Environment

  1. Install Microsoft Visual C# 2010 Express
  2. Install Microsoft Visual Web Developer 2010 Express installed (you can download all Express editions on one iso image at
  3. Enable Windows features:
    1. IIS Metabase and IIS 6 configuration compatibility
    2. IIS Management Console
    3. ASP.NET
  4. In IIS Manager, under Application Pools right click DefaultAppPool, select Basic Settings then change .NET framework version to v4.0.x
  5. Install Windows SDK. This can be downloaded from 

Create the Web Service

  1. First we will create the web service. To do this we need to run Visual Web Developer 2010 Express with administrator privileges so hit the start button type in “web dev” or similar and when Web Developer is highlighted press ctrl+shift+enter. This will start it as an administrator and show the UAC prompt. Alternatively locate Web Developer in the start menu then right click and select run as administrator.
  2. Select File –> New web site and choose WCF Service and name it MultiplyService
  3. Add code App_Code / IService.cs  
  4. Add code to App_Code / Service.cs
  5. Run the service by pressing ctrl F5 and click the Service.svc link in the page that opens. Nothing much to see here yet, you need a client to view this data. As indicated on the page you need to run the svcutil.exe utility to generate code that will be used by the client application

    The svcutil.exe utility is installed with the Windows SDK and can be found at c:\Program Files\Microsoft SDKs\Windows\v6.0a\bin

    To create the Service.cs file on the desktop try the following in a cmd prompt:
  6. That ends the WCF service. Leave all of this running, including the internet explorer window that Web Developer opened and open Visual C# Express to start on the client application.


Create the Client Application

  1. Start up Visual C# 2010 Express and select File –> New Project. Select WPF Application and name it MultiplyClient.
  2. Add a Service Reference

    In the Service Reference dialog paste in the address from the internet explorer window that web developer opened. Select the service and select OK
  3. Copy the Service.cs file on the desktop that was generated by svcutil into the root folder of the project
  4. Add two entry textboxes, a multiply button and a result textbox to the MainWindow.xaml
  5. Add code to MainWindow.xaml.cs to call the service when the multiply button is clicked
  6. Modify the app.config file. Simply change the contract value from “ServiceReference1.IService” to “IService”
  7. Press ctrl+F5 to run the WPF application. Enter two values to multiply and hit the Multiply button, you should see the answer in the result textbox!



  1. The basic gist of WCF services:
  2. Adding IIS features:
  3. Where to find the svcutil.exe utility:


  1. This comment has been removed by a blog administrator.

  2. This comment has been removed by a blog administrator.

  3. This comment has been removed by a blog administrator.

  4. There have been so many views of this post! Please feel free to leave a comment letting me know if you found this useful.

  5. Hey Ben,

    Thanks for a very straight forward post. I am clueless with Web Services or WCF Services for that matter, but I was able to at least follow your example and get it working on my system.

    I am building a WPF application that needs to run on systems located all over the world (working on their local networks), but will need to pull key data from our SQL server located in the head office. I was thinking I could call the SQL data into the WPF app using a WCF service. Is that how I would go about doing this? Can you shed some light on this?


  6. You are good Ben. After carefully following directions and paying attention to detail, I got both the client app and web service working like a charm. I owe you one! Thank you for taking the time to share. Your efforts have not been in vain over here. :*-)

  7. Sharing a post on building a web service client with WCF, at

  8. Awesome Introduction to Creating WCF Web Services and accessing using a WCF client.

    Your level of detail made this process unbelievalbe simple...

    Much appreciated!!

  9. Thanks, it was useful. The new terms really confused me when I started VS2010 for first time.

  10. Hi,

    Thanks for sharing this info. I will surely look forward at this.

    Internet Marketing Firm

  11. Hi. In the client code there is the line "ServiceClient svcClient = new ServiceClient()" How does this line reference the web service? It seems sort of generic and we aren't passing any parameters to it to specify what web service we are talking about.. How does it work?

  12. tnx alot mate..... this was my 1st WCF web service and it worked @ first shot..
    tnx alot.. cheers

  13. I've a solution with 5 layers-Entity,Data Access,Exception,Business and UI. My Data Layer being WCF service and my UI is an asp .net web application. When i run the app, i get end point not found error. But I've put the service reference app config into UI... pls help

  14. a Web Design Company, produce the ideal reflection for your business by our creative and exclusive layouts.
    web design company

  15. Hi Niranjan. Hope you got your problem resolved by now.
    Had the same problem. In my case, I was using the WCF service with a Class Project (dll). Seems that you have to add the .config file to your main application for it to work.

  16. Ben,
    I hope you're still working with this stuff.
    I can build and run the service, and access the service while it is running in Debug mode from the client.
    Now, I'd like to "publish" (?) the service to my localhost (IIS 7 on Windows 7), and access the running service from the client. (Without having to run the service in debug mode from Visual Studio 2010 pro.)
    Can you direct me to some instructions on how to make the service run under IIS?

  17. found my answers here:

  18. Hey Ben,

    I just want to say "thank you" for your time putting this together. I got my very first WCF service working properly using ASP.NET as client

  19. a Web Design Company, produce the ideal reflection for your business

    by our creative and exclusive layouts.
    web design company

  20. Somewhat useful. I keep having problems creating a service, especially the part where you say create the service from the command prompt. It won't work for me.

    I get up to the part where I am to put the code behind the button but there is no way I can refer to my service using your example.

  21. Service:

    Step 6 doesn't mention that you need to copy the url from the browser window in step 5. That becomes the final parameter for the svcutil.exe command.

    Also appears the MS changed the path to svcutil.exe. Might be dependent on OS. For me under Windows 7, it's now under ../v7.0/bin.

    This means the final command looks like:
    "C:\Program Files\Microsoft SDKs\Windows\V7.0\bin\svcutil.exe" [URL FROM STEP 5]


    Step 3.
    If you drag and drop the service.cs file into the solution window, it will add automatically. I used explorer to copy, so I also had to do do an Add Existing File, service.cs

  22. i didn't learn before about WCF Web application! you have given me a great idea about this application, thanks for the very knowledgeable work.
    web design company in pakistan

  23. I'd like to learn how to make this with a web client. Would you be able to show how this would be done?

  24. nice article you have posted here , this is very informative and very usefull to get ideas for making a website look. thanks best web design company If you want to design a corporate website then many things you should look before choosing a web designer.
    wen design Duabi

  25. Hi,Color psychology, and using yellow as an example in planning websites is a superb way to make elements stand out from the remainder of the site in Web Design Cochin, and the colour red is awfully evocative, which has a tendency to bring a memory, mood, or photographs, for instance, lightly or indirectly to mind.Thanks.....

  26. I was able to at least follow your example and get it working on my system.
    Java application development

  27. nice article you have posted here.thanksmore info

  28. This site and this post very help full for all visitor any can get help by read this content and site.

    Or any body can get more help this wp web design site.

  29. The Seattle Seahawks continue to defy convention, winning games with a blueprint that differs from the other 31 teams in the league.
    wholesale 2014 new jerseys
    2014 new nike nfl jerseys
    2014 nfl hoodies jerseys
    nhl hoodies jerseys

  30. Amazing thing you post in this blog. It help me to solve my related problem. Nice bolg post.
    Visit :- CS Service

  31. Delta Decisions Inc. is a premiere web development firm specializing in e-commerce and business websites. We offer services including website design, web hosting, SEO servives, pay-per-click, google adwords, website branding and much more.
    website hosting Toronto

  32. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!

    melbourne web designer

  33. it have usually determinant developing and Creating a WCF Web Service with VS2010 Express. thanks to represent this configuration.

    Perusahaan jasa seo | seo service company

    jakarta seo perusahaan | jakarta seo company

  34. We have solutions for all your needs. From conception to completion, quality is always paramount. Web Design Dubai

  35. Bergabung Dan Tunjukkan Cara Bermain Pokermu.
    Bersama GadisPoker Dan Menangkan Hadiah jutaan Rupiah.
    Dan Jangan Lupa Juga kami Ada Promo Buat Anda.
    Untuk Info Lebih lanjut Silakan hubungi CS (custumer Service).
    -Live chat ( gadispoker )
    -Whatsapp : +855966624192
    -BBM : D87DB681
    agen judi poker online terpercaya di indonesia

    bandar judi poker online yang paling aman

    taruhan judi poker online terpercaya

    poker online

    judi poker

    dewa poker

    raja poker


    judi poker online terbesar

    judi poker online yang aman dan terpercaya

    bandar poker online indonesia

    judi dewa poker terbaik indonesia

    agen poker online indonesia

    poker online betting

    poker online terbaik

  36. Thank you for sharing this. I love reading about design and how responsive works. Great information here.
    Nadkaar Agency

  37. wow amazing, i will definately go for these helpful tips thanks for sharing.
    Organic SEO

  38. insert intext:"nice article" "thanks" "Nice to meet you" "leave a comment"
    judi dewa poker terbesar

  39. i really appreciate your articles im a daily reader of your articles i love your informative tips and paragraph which are rich of useful knowledge thanks for sharing
    Public Relations Dubai

  40. Thank you for sharing informative guide in this blog.really appreciate it.
    SEO experts Dubai

  41. Its appreciable that how nicely you wrote. Really informative.
    PsdConverters - Wordpres to HTML

  42. interesting articles and this is my first first reading a very interesting article thanks for this article that fits with the theme news.
    domino qiu qiu

  43. It was an excellent information about your business and service! Thank you for sharing it with us
    ALOMaids - Maids Dubai

  44. interesting articles and this is my first first reading a very interesting article thanks for this article that fits with the theme news.

  45. interesting articles and this is my first first reading a very interesting article thanks for this article that fits with the theme news.
    dewa poker

  46. interesting articles and this is my first first reading a very interesting article thanks for this article that fits with the theme news.


  47. interesting articles and this is my first first reading a very interesting article thanks for this article that fits with the theme news.
    poker online terpercaya

  48. Howdy guys!!
    This is such a great resource that you are providing and you give it away for free, your content is brilliant as always, thank you so much for sharing this nice articles with us, they are helpful in all ways, keep on sharing...!!
    Web Designing Companies in Dubai

  49. The Fourdy Network; Leading Digital Marketing Company & 2D 3D animation studio Offers Seo, Social Media Marketing, Website Development, Mobile Apps Development, Lead Generation Services In Dubai UAE Malaysia & India.

  50. This is genuinely an awesome read for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
    Web Development