Liss
Liss

Reputation: 95

How to use my wcf services?

I’m working on a project where my class use a couple of wcf services. I use multiple test wcf services and multiple wcf services for production. I need to call may test wcf services when I have to use the test endpoints and I have to use the production wcf services when I have to use the production endpoints. The test wcf services and the production wcf services are equal.

Ex:

wcsServiceTest – endpoint: https://www.organization.testendpoint.com

wcfServiceProduction – endpoint https://www.organization.prodendpoint.com

Both of the services provides the functions getAllCats and getSingleCat

I want to be able to switch between the test services and the prod services when I call my functions that use this services. I thought about making a Factory class, and to classes who are similar to each other (have exactly the same functions) except from the imports of the wcfs. My Test class imports the test wcf services and my Prod class imports the prod wcf. My Test and Prod class will then share the same Interface but the problem is when I do it like this I have to import the endpoints in my interface. Then I have to import both the test wcf services and the prod wcf services in my interface.

Is this a good solution or is there a better way to solve this?

Upvotes: 0

Views: 50

Answers (1)

Shiva
Shiva

Reputation: 20955

I might be missing something here, but why don't you use Web.Config Transformations, and override the WCF endpoint accordingly?

So

  • In your Web.Debug.Config, have the Endpoint for the Test Service Endpoint, and also any other Test-only AppSettings etc.
  • In your Web.Release.Config, have the Endpoint for the Production Service Endpoint as a Transform directive, and also any other PROD-only AppSettings as Transform directives.

When you build and deploy, the Web.Config that will be generated will have the correct environment specific settings including the endpoints.

With the Slow Cheetah AddIn, you can actually make Transforms and Preview them inside Visual Studio, so you can be sure the Transforms are getting applied when you do your Builds! Very neat feature IMO.

Upvotes: 1

Related Questions