asp.net mvc - Managing WCF configuration when your service references are abstracted behind an API -
i have domain logic exposed via wcf services. rather explicitly writing wcf proxy calls, etc. in mvc web application, i've wrapped wcf service references own project - myproject.bizlogic.endpoint - , added reference project web app.
this great keeping controller code clean , readable - endpoint exposes icrmsystem interface nicely abstracted methods retrievecustomerdetails(int customerid), , within endpoint class that's wrapped customerquery dto , fired off @ remote customerqueryhandler service. isolation testing, mock icrmsystem , test controller methods against mocked implementation.
thing - wcf needs lots of cryptic , delicate configuration, , @ moment have have whole system.servicemodel bindings , client configurations in web app's web.config file.
is there cleaner way of managing configuration - preferably part of endpoint abstraction module web developers don't need know wcf going on behind scenes? can put reference endpoint's config file web app somehow? or manage wcf configuration programatically instead of declaratively?
thanks,
dylan
it turns out can isolate configuration sections separate file, offers nice balance between keeping config isolated, , still allowing editing @ runtime.
my web.config contains:
<system.servicemodel> <bindings configsource="services/bindings.config" /> <client configsource="services/myservice.endpoint.config" /> </system.servicemodel>
which means actual endpoint ports/protocols/etc. can isolated in own subfolder. folder configured external (submodule) in our vcs, if change piece of infrastructure - say, move service onto different physical server - can update configuration, commit changes, update project dependency on configuration sections, , avoid having manually update config files in multiple deployed apps.
only caveat iis won't detect changes these files main web.config, after modifying 1 you'll either need touch web.config or restart web app. other that, works quite nicely.
Comments
Post a Comment