Maintenance and recovery of service Urls

Asked

Viewed 41 times

2

I am working on a Web Forms project that has a DLL, and in this DLL there are references to external services. We have 3 environments (development, homologation and production) and for each environment there is a specific URL for each of the services, in its version for the respective environment.

I am having problems managing the Urls of these services. In the Webforms project I have the web.config where I can use XML Transformations to store key/value sets, and this would solve my problem. However, in DLL I only have one file app.config and the same does not support Transformations. What is the most appropriate way to get my solution adapted to integrate with the correct environment, based only on the Configuration used during the Publish process?

Just to highlight my current template: I create a web.Config entry with the service URL

<add key="UrlServicoCep" value="http://url_dev/servico.asmx" />

Then I recover this value and the step as a parameter in the instantiation of the class in which the service is used:

string urlServico = ConfigurationManager.AppSettings["UrlServicoCep"];
var dao = new CepDAO(urlServico);

Summary: I want to generate a package for the desired environment (homologation or production) and that this generation of the package already has the correct URL applied to the web services that consumption.

1 answer

2


However, in DLL I have only one app.config file and it does not support Transformations.

Yes. Only install the following extension in your Visual Studio:

http://visualstudiogallery.msdn.microsoft.com/579d3a78-3bdd-497c-bc21-aa6e6abbc859


EDIT

If you don’t want to use the extension, I think the method is already very close to the appropriate one. I would only make a small modification:

string urlServico = ConfigurationManager.AppSettings["UrlServicoCep"] ?? "http://url_default/servico.asmx";
var dao = new CepDAO(urlServico);
  • But taking into account the native limitation of not having xml Transformation, how would you solve the problem?

  • @Tiagocésaroliveira Without considering the extension, I believe your mode is already suitable, with some options for security. I will edit the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.