Is my Windows Communication Foundaton Service configured correctly?

Published 27 January 7 11:55 PM | William

One of the really sucky things about doing presentations is that you have to learn what you're talking about first.  Actually, there's nothing sucky about learning things, it's just that at until you hit your learning curve, it can be frustrating.  It's after that point though that things become sucky.  Why?  Because all too often you start going "Wow, is this cool, I wonder if I can_____________" and then you give it a try. Some stuff works on the first pass, some stuff doesn't.  Then you start debugging and searching around, figure out how to make it work and you in my case, it usually takes something like the dog pooping on the floor to make me realize how long I've been zoned out on the computer. 

If you're familiar with Windows Communication Foundation (WCF) then you realize that it's so configurable its almost hard to fathom (I really woulnd't be surprised if the next version negates the need for code altogether and you simply flip around config file settings to do what you want).  Configuration is as cool as hard coding stuff is lame, but one problem with it is that it's fussy.  If you screw something up in a XAML file (which is similar in form to config files) for instance, the compiler jumps in and lends you a hand telling you rather precisely what you did wrong. If you screw something up in a configuration file for WCF, you get the same behavior you did with .NET Remoting (for the uninitiated, that means it just sits there and laughs at you as you try to figure out which word you incorrectly spelled).

So I'm trudging through a bunch of samples I was thinking about and then realized most of what I've done entails hosting the service in a Console application.  Time to take off the training wheels and host it in IIS right?  I ask myself "Hell, how hard can that be?"

I created my virtual director and started copying stuff over.  Carefully, I changed my configuration file settings.  Just to be safe I left out all the fancy stuff I was doing with CustomBindings and just left in the simple stuff.  "This should be a breeze" I'm thinking the whole time.  So far so good.  Normally, as I progress along each step of the way I test that part to make sure I got it right up until then, just so it's easier to isolate problems down the road should they arise.  My ego got ahead of my brain and off I went.

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<
system.serviceModel>
<
services>

<
service name="MarkBrownService" behaviorConfiguration="returnFaults">
<
endpoint contract="IKnightEmailHelper " binding="wsHttpBinding"/>
</
service>
<
service name="BlueCuckooService" behaviorConfiguration="returnFaults">
<
endpoint contract="IPeck " binding="wsHttpBinding"/>
</
service>
<
service name="SausageDogService" behaviorConfiguration="returnFaults">
<
endpoint contract="ITakeADump " binding="wsHttpBinding"/>
</
service>
<
service name="DigitalStripperService" behaviorConfiguration="returnFaults">
<
endpoint contract="IStrip " binding="wsHttpBinding"/>
</
service>


Now, the first of these is really lame but the other three do quite a bit of stuff.  I do a second glance to make sure everything looks ok and it does.  I hand coded the client classes and was pretty sure they were good. So I fire everyting up and I see this:

The contract name 'IPeck ' could not be found in the list of contracts implemented by the service 'BlueCuckooService'.

The contract name 'ITakeADump ' could not be found in the list of contracts implemented by the service 'SausageDogService'. 

The contract name 'IStrip ' could not be found in the list of contracts implemented by the service 'DigitalStripperService'. 

Wheewwwy, I screwed up every single one of them.  So I tried to eliminate them one at a time, same problem.  I check the name, check the interface name.  Both look good.  So what have I done differently?  I put the interfaces into a shared assembly, that must be it.  So I removed the project reference and copied the classes back into the project.  Double checked the namespaces and figured, this has to be it. But it wasn't.  I went through everything I could think of and nothing.  Fortunately, Nikki the sausage dog got that look in his eye that he usually does right before chewing up one of my shoes or taking a dump on the floor and sharing it with me.  Upon getting up I realized I had went wayy tooo far down WindowsCommuncationFoundation express today and needed to do other things like walk the dog. 

When I arrived back, I saw what the problem was by the time I got comfortably seating.  A lot of times things just work like that. 

So, take one last look at the problem and see if you can figure it out - it's totally glaring if you're careful. (If you've been a reader of my blog for a while, it's  a well known thing that I due and have done the same thing many times before. 

I tend to type fairly quickly and while I use both thumps to space with, I frequently double this the space bar.  In T-SQL and C#, it seldom matters. MS Word and Excel both just fix it for me.  So I don't even realize I"m doing it. But configuration files - well, I think that they were made by a bunch of German guys who though it'd be a great goof to give guys like me a hard time "So uuwwe really sink dat Lexus have betta quality control den der BMW, You fool, we'll teach you a lesson!"

So I looked around and looked around and realized I put an extra space in after an interface name. Ok, that's fixed. All is good. But each new service I added suffered from the same problem. This time I knew exactly what it was, but it was easy to mess up b/c of muscle memory in my fingers.

 A quick way to know if you're service is configured correctly is as simple as one like in a browers:

http://localhost:2361/CuckooService/EvilBlueCuckooService.svc?wsdl

 

Substitute the name and location of your service(s) and use the good old ?wsdl method to make sure it works. If everything is in place, a browser window with a bunch of nested funky looking xml should appear that looks like your service definition.  If not, well you gotta problem.  So simple to use, it's worth it's price in gold.

So far, I got the images of the Cuckoo coming out of his clock, the SausageDog making "pinchy loaf loaf" all wired into to a client UI.  If any of my reliable friends like KC , Brian Madsen , Sahil or Ryan wanna help me with the UI for the last one, I got the back end stuff worked out ;-)

And hopefully none of the Usual and BrainWashedGrievance Brigade
 will try to pee on our parade.  I have a lot of fun WCF samles which are pretty cool.

My next WCF post will be on "Doing things with Behaviors most people can only dream about..."

Comments

# Roland said on January 27, 2007 10:17 PM:

Next time, could you prepare a shorter lesson, please! My brain hurts from reading all those words, to arive at this simple conclusion: WCF good, BILL better!

# Marshall Harrison said on January 29, 2007 6:19 AM:

OK. I'm not part of the "reliable friends" and I'm not one of the "Usual" or the "brain washed".

So where does that leave me?

Search

This Blog

Tags

Community

Archives

News

  • William G Ryan William Ryan Bill Ryan W.G. Ryan Charles Mark Carroll Charles M Carroll
    My Blog Juice Microsoft MVP
    Bill Ryan W.G. Ryan William Ryan
    Cuckooz' MySpace Page View Bill Ryan's profile on LinkedIn
    My Profile on Twitter
    Please note that this is my personal blog and the opinions expressed are my own. Also, comment moderation is about one of the least important things in my life so please keep that in mind. I can't vouch for the authenticity of any of the posters so please don't hold me accountable. And whatever you do, don't pretend to be Noted Option Strict Off expert and AspFriend Charles Mark Carroll when you post. Doing so will lead him to become apoplectic and write absurd accusatory posts about me that are as coherent and thought out as they are factually correct. He does a stellar job proving his reputation is well deserved and he doesn't need any help from you making himself look foolish. If I have to listen to him banging his spoon off of his high chair one more time, I'm going to burst into flames so please don't make that happen!

    My other sites

    Cool Stuff

    Book Stuff

    Security

    ORM

    Data Access

    Funny Stuff

    Compact Framework Stuff

    Web Casts

    My KnowledgeBase Articles

    My MVP Profile

    Design Patterns

    Performance

    Debugging

    Remoting

    My Fellow Authors

    My Books

    LINQ

    Misc

    Speech

    Syndication

    Email Notifications