Skip to content

October 6, 2007

Day 3

The first chapter introduces WCF and presents why it was created in the first place. It started out with a decent history lesson, but not one that wasn’t usefull. I actually liked the first part of the chapter. I talked about how COM, DCOM, COM+ came around, and how that evolved. It also had a small blurb about XML and XML Schemas and how they work hand in hand. A similar example to the one in the book is:

<Toy>
  <Color>Red</Color>
  <Material>Plastic</Material>
</Toy>

can be the same as

<Toy Color=”Red” Material=”Plastic” />

So the “contract” that defines which of the two will be used is the XML Schema. The book also provides a “tip” to go to http://www.w3c.org to read more about XML Schemas, that seems dandy but that site is huge and serves HTML and pretty much anything else the World Wide Web Consortium deals with.
Anyway, the book gets down to business and has you set up Data Access Application Blocks for the Enterprise Library. One of the steps is to replace the database name. The book just has you edit the property in the left pane of the screen. However, if you installed the April 2007 version of the Enterprise Library you can just use the elipsis under the Connection String value and you get a nice DB connection popup to select the database. This also tests whether or not you can connect and so on… quite nice. The book has you save the config file you are working to you My Documents folder ( or Documents in Vista ), I chose to create a folder on the C:\ drive and save all my stuff from this book there.
The examples are actually pretty good, they walk you through step by step. Which I really like since I hate just sitting there and reading something and I love getting more hands on. The thing that I am wondering right now is exactly what Microsoft is thinking though. On one hand they are coming out with WCF, and some pretty cool stuff centered around that from what I can see. On the other they seem to be making it easier for numbskulls to code… Pardon the French but I think certain aspects of new technologies being released are not up to par, namely LINQ. I’ve been looking at that a tad, so I only know enough to be dangerous. However, the irresponsible use of variants and lack of “coding contracts” is just bothersome. Anyway, back to the book we go.

With WPF you can implement Data Contracts to define what will be passed to operations. You also need to define a service contract that will define the operations available, much like the WSDL… if I’m wrong feel free to correct me. I’m not a WCF expert, I’m reading through the book :) The service contract reminds me of C++ and defining method headers. You aren’t actually implementing the body of the method, you are just providing a list of what you plan on implementing. The service contract is an interface, not a class. One thing that should be noted is that all types within the data or service contract must be serializable.

The rest of the chapter has you work on the implementation of the service contract methods. Then it has you deploy the service. It did so in a rather manual way. First you have to edit the web.config manually, then add the site to IIS. I then remembered I never installed IIS since I just used the development server in 2005 on my laptop. No reason to bother with IIS until I got to the DEV server.

The last thing was to build a client application to use the webservice. The book had you create a console application, however I created a win app. Console apps are fun for hello world applications but I wanted something to click on.

Read more from Uncategorized

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments