Nate Bross Posted December 31, 2008 Posted December 31, 2008 I am about to be developing a solution in which I rely on several outside (out of my control) web services (both WCF and ASMX). Each individual service provides multiple methods and business objects that relate to said service. Each service also has a test/dev endpoint, as well as a production endpoint: test.service.com and production.service.com. This is sort of a two-parter: First, am I correct in that all I should have to do is swap the endpoint address from the app.config file when I am ready to go from test to production? (Assuming that I am able to get a valid token for production access?) Second, my application will be relying heavily on these services, but only using a limmited portion of their functionallity. Is it wise to make my own "wrapper" classes (in seperate class library?) and then have my application take advantage of my class library instead of directly talking to the services? Thanks for any responses! (Sorry for being longwinded) Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted January 3, 2009 Administrators Posted January 3, 2009 If the test and production services expose the same functionality then you should be able to just swap endpoints, asuming other considerations (like security) are taken care of. Personally I would only bother to wrap the functionality in my own class library if I was using these services in multiple projects or if these services had a overly complex / confusing API I was trying to encapsulate. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted January 5, 2009 Author Posted January 5, 2009 Thanks, the services do expose the same functionallity, so hopefully just swapping end points will work for me. I will probably be using these services in multiple projects and they are very complex and provide alot of functionallity (of which I'll only be using a small portion). So I think I'm leaning toward encapsulation. I know that you can define your own proxy in code and set your endpoints and other configurations there. Would it be a good idea to setup my class library to do this, and then allow an instance of my class to manage creating the proxy for each call? Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted January 5, 2009 Administrators Posted January 5, 2009 I would create a single classlibrary that encapsulates the useful functionality from the webservice and just exposes this as simple methods / classes to the calling applications. All the actual proxy instantiation etc. would be done entirely inside this dll and the calling applications wouldn't get involved directly. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted January 5, 2009 Author Posted January 5, 2009 My thought was to use an Enum Flag (Mode.Production | Mode.Test) and pass that as a parameter for instantiating the class initially. Is there a better design I might use? Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted January 6, 2009 Administrators Posted January 6, 2009 I would just shove the url into a config file and change the file when switching between systems. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted January 6, 2009 Author Posted January 6, 2009 Would this be the config file of said class library (myclasslib.dll.config) or in the application (myapp.exe.config)? This has always confused me... Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted January 7, 2009 Administrators Posted January 7, 2009 If you use VS 2005 or later's settings property page then the class library just gets a section in the calling applications config file - this way you can keep the code in one place (the dll) but configure it on an app by app basis. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted January 7, 2009 Author Posted January 7, 2009 Excellent, that is exactly the behavior I wanted to see. Solved. Thanks! Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.