This project is read-only.

Overview

One of the reasons I have avoided WCF like the plague over the years was due to the ridiculous amount of configuration that was needed. Having the ability to use multiple protocols and endpoints for the same service is really nice, but what if your needs were as simple as “I need to call something over http and get X back”? A scenario would be your typical service created for AJAX calls for some UI. ASMX web services provided a very simple and direct way to do these things without having to manage a bunch of crazy configuration entries.

With WCF 4.0 defaults for protocols, bindings, and behaviors are baked, and there is even a way to do the services without an actual .svc file (File-less Activation). You can get a great overview of these new features on MSDN: http://msdn.microsoft.com/en-us/library/ee354381.aspx.

While these are all great improvements, I still want more because I’m lazy and am always trying to find ways to work smarter, not harder, so enter SimpleWcf. SimpleWcf provides a way to essentially do “simple, configuration-less, file-less, WCF”. It works by discovering services using reflection and assumes a convention is used for the namespaces.

Getting started (using the example):

All that is needed to use SimpleWcf is to add a reference to the assembly and make the following two configuration changes (ok so it’s not entirely configuration-less!):

ConfigChanges.gif

Start the ExampleWcfServiceApplication project by hitting F5 and add Service1.svc to the end of the url like http://localhost:2861/Service1.svc.
Please note your port number may differ

baseService1.png

Now enter "list" on the end like http://localhost:2861/list to see a complete listing of the services available:

baseList.png

Note the service created in the ExampleWcfServiceLibrary.SubFolder namespace is now referenced as /SubFolder/Service2.svc. (Namespaces are converted to paths).
Also notice that you have the option to add a description to your service by using a description attribute:

ServiceDescription.png

Additional configuration

SimpleWcf can also be additionally configured as follows:

AdvancedConfig.png

useSvcExtension Services will not have a file extension (such as .svc) (not required)
serviceBasePath Provides a base path for all services (not required)
assemblies Scopes what assemblies should be used to discover services. (not required)


Example of all the settings in action:

settings.png

Note !

This code is provided as it, it was something that I just wanted to work out on my own, you should thoroughly test it before using it in a production environment.

Last edited Aug 13, 2010 at 4:13 PM by wojan, version 32

Comments

No comments yet.