How to configure a proxy class for an ASP.NET web service for flexible deployment to production -
i inherited web app @ visual studio 2003 level placed of code accessing sql server in asmx web service. web project had web reference web service. needed bring whole thing under source control, upgrade vstudio 2008 , make bunch of fixes , enhancements.
in doing this, came across neat article code magazine emphasizing advantages of "assembly separation". written wcf "inspired me" to:
- remove web reference main asp.net web application project
- add new project class library called proxyzipeeeservice
- add web reference in proxyzipeeeservice project point @ zipeeeservice project
- add reference in main web app project proxyzipeeeservice.dll produced building project of same name.
the things work , guess there [performance?] advantages separating things out having described structure, i need question/problem:
i run lots of configuration problems when deploy production require me make changes quite "awkward" , prone me screwing things up. here guess needs changing i've searched extensively , cannot understand how:
the proxyzipeeeservice project web reference in produces files follows:
- reference.map.vb, proxyzipeeeservice.disco, proxyzipeeeservice.wsdl , app.config
- on development pc, app.config file produced settings url of localhost (as should pc). please view xml entry at: http://pastebin.com/jtqcxt73
when publish web application project production web server, url webservice "buried" inside dll proxyzipeeeservice (which @ time in bin folder of web app because referenced).
because prod web server configured recognize "host header files" [another question someday], url localhost fails http 400 bad request. host header config requires related default website use domain http://www.zipeee.com/zipeeewebservice/zipeee.asmx
so fix this, have been having "dismantle" development project proxyzipeeeservice - deleting web reference, adding time make dialog point ws on production server (instead of letting find ws in "this solution" because results in problematic "localhost" setting).
eventually able push out prod server web project referencing proxy dll won't run host header issue , works without throwing http 400 error.
but there has better way!
in short, critical proxy dll cannot configured regard url should use way i'm set now. i've tried putting applicationsettings entry app.config web.config of web application project. i've tried putting variation on appsettings section. both of these attempts fail.
i hope have been clear , not been verbose. please not suggest major surgery wcf because can't bite off on project. thank reading , in advance help.
edit update: changing url in web app's web.config not detected! problem remains. here did:
- followed said do, lifting settings app.config of proxy web.config of web app (establishing new configuration section group points setting app.config.
- the value in proxy , in web.config reads as: http://localhost/zipeeewebservice/zipeee.asmx fine testing on dev pc
- before deploying production server, thought should test bit. first test settings above , set breakpoint in web service project , verified proxy had indeed come localhost web.config entry intended , expected.
- next (test case 2) changed web.config entry localhost www.zipeee.com production webservice public facing web app uses.
- i left same breakpoint in first web service call in place (expecting not hit because intention use url specified in web.config)
- to surprise, breakpoint hit , when examined url via immediate window, showed localhost (should have been www.zipeee.com desired in web.config).
perhaps have misunderstood approach should allow? there missing? did not rebuild proxy dll (that remains localhost) thought whole intent (i.e. able control url in sort of "late-binding" way via changes web.config of web app).
i remain stumped. hopefully, me bit more...thanks.
edit update: 12 oct
thanks - read notes i'm still confused. proxyzipeeeservice project code generated web reference. here snippet reference.vb file (are suggesting modify generated code?):
public sub new() mybase.new me.url = global.proxyzipeeeservice.my.mysettings.default.proxyzipeeeservice_wszipeee_zipeee if (me.islocalfilesystemwebservice(me.url) = true) me.usedefaultcredentials = true me.usedefaultcredentialssetexplicitly = false else me.usedefaultcredentialssetexplicitly = true end if end sub public shadows property url() string return mybase.url end set if (((me.islocalfilesystemwebservice(mybase.url) = true) _ andalso (me.usedefaultcredentialssetexplicitly = false)) _ andalso (me.islocalfilesystemwebservice(value) = false)) mybase.usedefaultcredentials = false end if mybase.url = value end set end property
by way, comment on whether whole idea of separate assembly (proxy) web service worthwhile thing. there may performance benefits (?) these configuration issues giving me fits.
edit-update 12 oct - bit later
after last posting of code generated file reference.vb, spotted problem! declarations had me place in web app's web.config file named:
section name="proxyzipeeeservice.properties.mysettings"
while reference.vb file refered setting as:
me.url = global.proxyzipeeeservice.my.mysettings.default.proxyzipeeeservice_wszipeee_zipeee
changing web config name read section name="proxyzipeeeservice.my.mysettings" has enabled proxy find setting in web app's web.config , i'm able "toggle" web service url through configuration parameters.
thank help. closing now.
p.s. "professionals" use proxy classes wrappers web services this?
you should place configuration in web.config of web app, making section group references proxyzipeeeservice project. so, copy both sectiongroup , actual applicationsettings proxyzipeeeservice web application:
<configsections> <sectiongroup name="applicationsettings" type="system.configuration.applicationsettingsgroup, system, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"> <section name="proxyzipeeeservice.properties.settings" type="system.configuration.clientsettingssection, system, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </sectiongroup> </configsections> <!--other stuff--> <applicationsettings> <proxyzipeeeservice.properties.settings> <!--your original appsettings--> </proxyzipeeeservice.properties.settings> </applicationsettings>
then can change settings after application has been deployed.
if else fails, make proxyzipeeeservice library expose url public property, can changed @ runtime web application calling it.
i hope helpful.
Comments
Post a Comment