Note that there are some explanatory texts on larger screens.

plurals
  1. POEncapsulating WCF Proxies in Static Classes
    text
    copied!<p>I am designing a web service which will call different external web services according to the properties of a given object (a "request", for instance). A reference to these web services is added through the "Add Web Reference" menu in Visual Studio 2008, which, as you know, creates a proxy class for each endpoint which inherits from <code>System.ServiceModel.ChannelBase&lt;ISomeInterface&gt;</code> (where <code>ISomeInterface</code> is the endpoint defined by the specific service's WSDL).</p> <p>The question is that I would like to encapsulate all those proxies in a single <code>ServiceManager</code> (for instance) static class containing, for example, an internal list of all the proxies, so that, on the one hand, all calls to a given service may go through <code>ServiceManager</code> instead of being scattered around the main application, and, on the other hand, new services which may be added latter can be made known to <code>ServiceManager</code> by a simple addition of a reference to the new proxy class.</p> <p>I thought about desinging <code>ServiceManager</code> like</p> <pre><code>public static class ServiceManager { #region Properties public static Dictionary&lt;string, TProxy&gt; ServiceList { get; private set; } #endregion } </code></pre> <p>but I don't know what I should replace <code>TProxy</code> by so that all of the different proxies can be called by using <code>ServiceManager.ServiceList["ServiceName"]</code>. Can anyone please help me out with this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload