This is a mirror of official site:

WCF Configuration without Configuration

| Monday, February 4, 2013
Before Christmas, I worked on automatically creating WCF configuration from a WSDL document.

I got until the point where I can successfully create a ServiceEndpoint and its Bindig from the WSDL (ServiceContractGenerator.cs:843 in my baulig/work-wsdl-config2), but run into several problems when creating the .config file.

The first issue I ran into was merging the new configuration items that were generated from the WSDL into an existing app.config file. The main problem is distinguishing elements that the user manually put into the app.config, new items from the WSDL file and items from the WSDL file that were previously added automatically (running "Update Service Reference" twice in MonoDevelop shouldn't add configuration twice). Visual Studio uses the configuration.svcinfo / configuration91.svcinfo files to cache the elements that it added to the app.config, but their format is undocumented (it's XML, but there's a checksum element, I've no idea how to generate that and didn't find any information on the internet).

The second big issue is automatically configuring a WCF client without System.Configuration, so it can be used in MonoTouch.

Microsoft uses some .xml inside a .zip file for Silverlight (but I also couldn't find any specification for the format) and Mono is using the SilverlightClientConfigLoader class to parse an file. But this class is incomplete, only handles the very basic cases and doesn't provide any useful error reporting to the user.

And the third big issue is that our System.Configuration implementation is buggy and the many of the System.ServiceModel.Configuration APIs unimplemented.

So I was thinking about a solution which satisfies the following requirements:
Does not use Reflection or System.Configuration, so we can use it for the mobile platform.
Allows automatic configuration of a WCF client from a WSDL document - so you simply do "Add Service Reference" in MonoDevelop and it sets you up just like Visual Studio does, without any manual editing of configuration files.
Is at least somewhat compatible with the app.config format.
The Solution
The solution I finally came up with was a custom XML file format.

It is very similar to the section in the app.config file, but not identical. The main difference is that the name of each XML element is unique and doesn't depend on the context it's used in.

QR: Inline image 1

Posted via email from Jasper-net