mattmc3
mattmc3

Reputation: 18325

Can you set up a WCF Service Reference without cluttering up your app.config?

I have a dirt simple web service hosted in IIS that I need to reference. If I add a 'Service Reference', my app.config gets cluttered up with tons of <system.serviceModel> stuff. If I change the Service Reference to the old style Web Reference, I get the one and only configuration option I actually need in my app.config - the URL of the web service.

Is all the junk that a WCF Service Reference pollutes your app.config with required? Or is there a way to get it to use reasonable defaults and remove all the bindings and endpoints and clutter that was never necessary in the old ASMX web service days. As more and more services are added, this seems like the .config file is going to get unwieldy fast.

Upvotes: 2

Views: 795

Answers (3)

marc_s
marc_s

Reputation: 754268

Check out Miguel Castro's Extreme WCF screencast with DotNet Rocks TV - he shows exactly what you're looking for, and how to achieve nice, clean WCF configs (as long as you don't let Visual Studio and svcutil mess them up!).

Upvotes: 2

Vlad Bezden
Vlad Bezden

Reputation: 89507

.NET Framework version 4 addresses these problems and provides users a way to reduce the size and complexity of service configuration. Here is the link for Simplified Configuration

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Is all the junk that a WCF Service Reference pollutes your app.config with required?

Totally agree with you. Pure junk. I use svcutil.exe to generate strongly typed clients to my WCF services. Then I manually include the generated .cs file into my project and in my web/app.config I manually include what I judge necessary and not what some crappy Add Service Reference Wizard decided to do. In most cases all I need is this on the client side:

<system.serviceModel>
    <client>
      <endpoint
          address="http://example.com/fooservice/foo.svc"
          binding="basicHttpBinding"
          contract="IFooServiceConbtract" />
    </client>
</system.serviceModel>

Of course for services where I use MTOM and some fancy stuff I look at the autogenerated app.config file by the svcutil.exe command and I decide what I need.

Upvotes: 2

Related Questions