Yes, the behavior of the Add Service Reference
part in Visual Studio is a major PIA - and it's not been improved a single iota in VS 2010, unfortunately :-((
And even more unfortunate, you cannot really tell the importer to leave your existing stuff alone - what I do is create a backup of my web.config, import the WCF service and let the importer mess up my web.config, and then I just slap my backup over the mess again and go about making the necessary additions manually.
One alternative is to use svcutil.exe
on the command line - first of all, you can tell it to /noconfig
and skip messing with your config (or you can output the recommend config into a separate config with a different name), and secondly, it'll happily create your client-side proxy service class in a C# or VB.NET file for you, ready to use.
But yes - of course you can add all the necessary information by hand!
In a typical client side config, the most important point is the <client>
tag - just add whatever it is you need - using the "ABC of WCF" - (A)ddress, (B)inding, (C)ontract:
<client>
<endpoint name="something-useful"
address="your-address-on-the-server"
binding="wsHttpBinding" -- or whatever it is you're using
contract="IYourServiceContract" />
That's the minimal client-side config you need. Anything else is just additional stuff, used when needed. This uses all the default settings for your binding, obviously.
Here are two really good videos that show how to do a lot of manual WCF configuration - sounds scary, turns out to be much easier than deciphering the mess the VS importer creates....