Welcome

You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

ASP.NET Web Services and WCF Very Different Animals

Posted by Keith Elder | Posted in .Net, Asp.Net, Web Services | Posted on 27-02-2007

For the past several days I’ve spent a lot of time trying to get up to speed using Windows Communication Foundation.  I’ve seen or watched enough “Hello World” demos of WCF over the past year to choke a good mule to death but I haven’t had a chance to write anything using WCF for real world experience.  I knew I’d get around to it eventually.  This is the point where you actually learn how to use a technology anyway.  Having done large scale applications with Asp.Net web services for quiet sometime I honestly didn’t figure it would be that difficult.   I was wrong.  My first real world venture into WCF left me scratching my head and feeling like a 12 year again. 

My reason for using WCF is I’m staring a new project which will be a Smart Client application used to build and manage business rules for different .Net applications leveraging the Windows Workflow Foundation rules API.  Since I was leveraging the .Net 3.0 framework anyway, I thought now was as good a time as any to jump into WCF. 

Once I defined my database structure and calculated which web service methods I was going to need, I created my ISomethingInterface contract which defined my methods.  I then implemented those methods in my service.  Very simple stuff at first, then I pressed F5 in Visual Studio and I was greeted with errors because my web.config file wasn’t configured.

I knew I had to configure the service and so off I went researching how to write the web.config file to expose my service.  I went to MSDN only to learn that I was going to spend the next several hours reading all of these different configuration options (WCF is flexible, but with flexibility comes more to read).  I gave it a college try trying to configure the web.config by hand and then eventually got frustrated because it wasn’t working.  Finally after doing some other searches I see a screen shot of a new item menu in the context menu when you right click the web.config file called “Edit WCF Configuration”.  I click it and get this:

If I’d only know this was there earlier.   After I got my service configured so it gave me a result other than an error page I *thought* I was going to get the same type of page you get with normal Asp.Net web services which is a page that shows you the methods available.  I was wrong.  I got this:

Where’s my list of web methods!?  Not there.  Again different from what I was expecting.  By this point I had resigned myself to throwing everything I knew about ASP.NET Web Services out the window because obviously previous knowledge was not really helping. 

I decided to absorb my new service in my client.  Since I had gotten burned by the right mouse click thing earlier I decided to see if the WCF CTP put a menu item in my project so I could generate the class file with svcutil.exe instead of wsdl.exe. Sure enough it was there.  This was the only thing that left me warm and fuzzy, something I had done before.   I then wrote a quick line to leverage the service (which I had placed in a separate Class Project) and it didn’t work.   The app.config file generated was placed in the project file where the service was generated, but not in the project the application was going to run from.   Luckily I was smart enough to just copy the one created for me and it worked.  Again, different. 

Feeling I had made progress I made the methods I wrote work, wrote unit tests for them and then baked them into the user interface of the application.  Then it hit me that I needed to call these services asynchronously.  So I typed “service.” and waited for intelilsense to see what the async calls were named.  They weren’t there!  Uh oh.

Doing some more digging I learned the svcutil.exe has a switch to generate asynchronous calls. The switch is /async.  Reading further there are different types of async calls and this is where I am currently at, trying to figure out what I really need to do and all the ins and outs of async calls in WCF.  Obviously lots of differences as I move further into WCF.

I did find a really good article which tells the developer what the differences between the two are, you may save yourself some headaches.  There are also some other documents nearby this one in the menu on MSDN that you may want to read as well.

Comments (7)

I right click on web.config and i don’t get the option to edit WFC.

We are still stuck with stub code being generated in the client so any default properties are lost and i want a baby that can run, has client side methords and not millions of lines of code generated behind the scenes.

WCF is just web services with more to go wrong IMHO and i have yet to see any advantages.

I right click on web.config and i don’t get the option to edit WFC.

We are still stuck with stub code being generated in the client so any default properties are lost and i want a baby that can run, has client side methords and not millions of lines of code generated behind the scenes.

WCF is just web services with more to go wrong IMHO and i have yet to see any advantages.

@akshita There isn’t a question or anything, it is a statement “asp.net webservices and wcf are different”. For those exploring WCF and that have done asmx services it is very different. No question just a statement.

hey can u pls repeat ur Q, as wht u r trying to ask precisely, may be i can help u as im working wth wcf since3 months , n i found it not so hard

I think I’ll wait until the Keith Elder demonstration video is created, which should be less than a month from now.

Here is a good way to describe WCF I think. Brian Noyes described it like a 747 cockpit in an older entry. Now that I’m into it, I would agree 100%.

http://www.softinsight.com/bnoyes/PermaLink.aspx?guid=0a11df39-72f7-47fb-a0a8-7222e0c8d19c

It’s good to know that I’m not the only person who hasn’t deployed “real-world” WCF code yet. Jeesh, the stuff just went live and I already feel like I’m two-years behind!

Write a comment