0

Context

We have developed the application from end-to-end using .NET Stack. So, let's say we are managing something like this:

WPF Client <=> Web Service:

  1. Development) Plain reference (direct calls to the WCF Service project inside VS, not deployed in IIS)
  2. Production) Remote Web Service [IIS @ remote server, need VPN to connect]

Web Service <=> Database:

  1. Development) SQL Server Express local DB [@ development machine]
  2. Production) SQL Server DB [@ production server, same as WS]

Notice that I've implemented it "The manual way, the right way" (http://www.code-magazine.com/Article.aspx?quickid=0809101). Hence, separate contracts / client proxies and so on ...

Question

How could I get a set-up like described before in an elegant way? I mean, the web service <=> database it's trivial, since I can use the web.config transformations in order to switch the connection string between debug & release. But, how can I automatically switch the "connection" from the client app to the Web Service?

In production I'm using a reference to the proxies, and describing an end-point in the app.config file. I guess that in development I would just need a plain reference to the web service itself. [Should I add/remove references between debug/release configurations? If yes, how could this be achieved programatically? ... I'm completely lost].

Thank you for your time guys! ;)

EDIT:

As @AlexanderBalte suggests, the development behavior is just a direct call of methods. I don't have an app server in the main development machine.

  • I think you only need to change the service endpoint url to the one used in production. – prthrokz Jan 09 '13 at 19:56
  • Is your development behavior just a direct call of methods without interaction with web service? – Alexander Balte Jan 09 '13 at 20:04
  • what's wrong with using config transforms for the service endpoint configurations? If your concern is with transforms on an App.config check this out: http://stackoverflow.com/questions/3004210/app-config-transformation-for-projects-which-are-not-web-projects-in-visual-stud – Didaxis Jan 09 '13 at 20:21
  • As @AlexanderBalte suggests, my development behavior is just a direct call of methods. I don't have an app server in the main development machine, thus ... no endpoint. In fact, that was the point of the question :P – Carlos Murdock Jan 10 '13 at 08:32

2 Answers2

1

Just like prthrokz, commented, we just switch endpoints. Using conditional compilation symbols is about as simple as possible (but no simpler):

    WCFServiceClient client = new WCFServiceClient();
#if DEBUG
    client.Endpoint.Address = new EndpointAddress(new Uri("http://devSrv/WCFService.svc"));
    client.Endpoint.Name = "Dev";
#else
    client.Endpoint.Address = new EndpointAddress(new Uri("http://prodSrv/WCFService.svc"));
    client.Endpoint.Name = "Prod";
#endif
Community
  • 1
  • 1
vinny
  • 1,810
  • 15
  • 21
0

As I understand, development behavior is just direct call of methods and production behavior is interaction with web-service through generated proxies.

Respectively, in development and production you are working with different classes, but with simmilar set of methods.

Perhaps we should create another proxy interface with exact set of methods like web service has. There will be two implementations of this interface: one would be to proxy direct method calls, another - web-service method calls.

Also, you will need to write a Factory class which will provide you concete implementation of your proxy interface depending on some configuration in your app.config.

Alexander Balte
  • 900
  • 5
  • 11