views:

23

answers:

1

Here is my scenario...I have a WPF app that talks to a WCF service.

The connection string settings are in the WCF service. The WCF service can be deployed to two different web sites, one for QA and one for PROD (each with its own URI).

I want my WPF app to be able to be run using QA data or PROD data. Basically, I would pass a parameter on startup to the WPF app which would be QA or PROD.

What I would like to do is deploy the exact same WCF service code to the QA and PROD websites with the only difference being the values of the connection strings in the respective web.config files.

I would then need a way to have a factory pattern in the WPF app that would return the WCF interface (proxy) based on the QA/PROD parameter passed in.

I need to make sure in the WPF app that the WCF interface (proxy) is viewed as the same type in both the QA and PROD reference.

After all this, the result would be...if a user started the WPF app and passed QA, each call to the WCF service would return QA data and if they passed PROD, each call to the WCF service would return PROD data.

I could simply pass QA or PROD as a parameter to each WCF service method, but that seems crude. Since WCF is stateless and has no constructor, I need to find a more flexible solution.

+1  A: 

Is it not an option to have the service deployed to 2 separate URL's?

  1. Service URL 1 - QA URL --> this web.config has QA connection string
  2. Service URL 2 - PROD URL --> this web.config has PROD connecting string

The WPF app which is using the WCF service most likely just has its own config file with the service host.

In WPF App,

if you need to connect to QA URL --> you change the app.config to point to URL1

if you need to connect to PROD URL --> you change the app.config to point to URL2

This would greatly simplify your problem, if i have understood it correctly.

This way, there is no logic in your application where you are deciding which DB to connect to. Its just a simple question of having the right URL configured in your application and everything else just flows from there.

InSane