WCF Configuration Editor

28. February 2007 08:10

If you are already familiar with the WCF Configuration Editor, this post isn't for you.  If you have no idea what I am talking about, please keep reading.

Unless you are a masochist or simply possess an exceptional love for angle brackets, the act of creating and modifying xml configuration files isn't exactly fun.  Sure, it isn't a big deal to modify an app.config to include a few key-value pairs in the appSettings section.  However, if you find yourself deep in the structure of a particular configuration section dealing with some obscure attributes, it can become a real pain.  Granted, it became significantly easier to do this sort of thing with the introduction of xml intellisense in Visual Studio 2005, but it got even easier with .NET 3.0 for WCF service configurations.

With the .NET 3.0 SDK, a utility was included to edit WCF configuration files via a GUI.  This little utility can be rather handy for people (like me) that don't particularly enjoy modifying deep xml configuration structures by hand.  Using the utility, it is possible to modify any aspect of a WCF configuration.  Now, there are times when it is overkill to use a GUI to make a simple configuration change.  But, it is quite useful for some of the more advanced configuration scenarios.

The utility is accessible from the context menu when you right click on a configuration file from the Solution Explorer in Visual Studio.  Simply select the "Edit WCF Configuration" menu option, and away you go.

The easiest way to get a feel for what this utility can do is to play around with it.  For a brief example, let's use it to create the custom Http Binary binding I posted about last week.

Right click on the Bindings folder of the Configuration pane and select the context menu option "New Binding Configuration".  A dialog window will appear that prompts you to select a binding type.  For this example, we are going to create a custom binding.  So, select the customBinding option.

This will create a new custom binding pane with the possible configuration options.  Notice the Binding Element Extension Position section in the lower right corner of the utility.  This is where binding elements can be added, removed, and re-ordered for the custom binding.  The utility adds default binding elements httpTransport and textMessageEncoding.  Remove the textMessageEncoding and replace it with binaryMessageEncoding.  Also, add a reliableSession binding element at the top position.  Remember the order is significant since it will dictate the binding element position in the communication stack.  Change the name of the binding to NetHttpBinding.

Finally, the applicable service endpoint must be configured to use the custom binding.  Expand the services folder.  Under the applicable service, expand the endpoint folder.  For the http endpoint, set the Binding to customBinding and the BindingConfiguration to NetHttpBinding.  This instructs the endpoint to use the previously configuration custom binding.

Note: This example was based on a service and endpoint already being defined in the service configuration.  If they do not already exist in the configuration, it will be necessary to create the service and endpoint as well.

Whether this is a useful tool to avoid manually modifying service configurations or simply an unnecessary tool that just slows you down, only you can be the judge.  Personally, it is handy to me when dealing with complicated service configurations.  But, different strokes for different folks.

Later this week, I will be posting about using the service trace viewer to get a closer look at what is going on with your service.  It will touch on the WCF Configuration Editor for the purpose of quickly enabling the diagnostics output.

Comments

4/20/2007 11:18:28 PM #

http://

quote:


"Unless you are a masochist or simply possess an exceptional love for angle brackets, the act of creating and modifying xml configuration files isn't exactly fun.  Sure, it isn't a big deal to modify an app.config to include a few key-value pairs in the appSettings section.  However, if you find yourself deep in the structure of a particular configuration section dealing with some obscure attributes, it can become a real pain."


uh. no. if they had designed it using some common sense and had made a heirarchal schema (you know, like xml usually is), and used some intuitive conventions, then it wouldn't have been this way. but clearly some lackey designed this, because they really screwed it up.

http:// |

4/21/2007 9:47:43 PM #

Bryan:

Your argument doesn't really make sense.  

The xml configuration is hierarchical (you know, like xml usually is).  And, I really don't see how the fact that WCF provides extensive support for xml configuration indicates "some lackey designed" it or that "they really screwed it up."  

WCF is actually quite powerful and extensible.  Personally, I would say there was an impressive amount of time spend on the design.  

I was only pointing out that it is easier to use the provided tool rather than manually creating an xml configuration file.  Why not use a tool if it saves time?  It would be like writing an application with Notepad.  Sure, you could do it.  But, why would you forfeit the rich development environment of Visual Studio?

jeff.barnes |

8/30/2011 10:59:03 AM #

pingback

Pingback from blog.davidrenz.com

davidrenz.com   » WCF Service Returning a Strongly Typed List

blog.davidrenz.com |

Comments are closed

About Me

I'm a passionate software developer and advocate of the Microsoft .NET platform.  In my opinion, software development is a craft that necessitates a conscious effort to continually improve your skills rather than falling into the trap of complacency.  I was also awarded as a Microsoft MVP in Connected Systems in 2008, 2009, and 2010.


Can’t code withoutThe best C# & VB.NET refactoring plugin for Visual Studio
Follow jeff_barnes on Twitter

View Jeff Barnes's profile on LinkedIn

 

Shared Items

Disclaimer

Anything you read or see on this site is solely based on my own thoughts.  The material on this site does not necessarily reflect the views of my employer or anyone else.  In other words, I don't speak for anyone other than myself.  So, don't assume I am the official spokesperson for anyone.