Reputation: 30837
I have a single WCF service but, until runtime, I don't know the correct address of the service. It may be :
http://example1.com/MyService.svc
// or
http://example2.com/MyService.svc
The service is used by a class library (DAL). I have two options:
Which option to use? Also if option two is recommended by you, then should I my client wrapper class be singleton or I can create all the connection stuff on each call?
Upvotes: 1
Views: 479
Reputation: 1062550
Option 1 - you get all the advantages and none of the pain. Just use something factory-oriented (i.e. Don't do new MyProxy()
, but instead stick that code somewhere central like a static CreateMyProxy()
method, or consider an IoC/DI container).
How to consume WCF web service through URL at run time?
Upvotes: 1
Reputation: 44605
you can point to localhost or any other address in development then in production if the url changes you simply modify the web.config or the app.config where you have configured the WCF end point.
Upvotes: 2