How do I call WCF services dynamically from a .Net client application?

Posted on 2012-09-06
Last Modified: 2012-09-13

I've got a WCF Design/Architecture question.

I've got a WPF based front end which will talk with 1 or more WCF services on the backend.
The Services are designed so that their method signatures will all be the same.
So the the basic architecture looks like this:

                                   WPF Client App
                                      /       |       \
                             WCF1    WCF2     WCF3   ...   ... WCFN

Ultimately, I'd like to be able to to connect to these services dynamically.
So at runtime I've got 1 to N services I can connect to. I want to determine at
runtime which service endpoint to connect to, based on some user contextual data.

Remember that my method signatures will be the same across all services.
I will be making the same calls. I don't want to have to distinguish between services
on my user panels code behind.

This method will allow us to extend the service offerings dynamically without affecting the client (WPF based) installation.

What's the best way to achieve this?
If there is some trickery involved, is it best to handle that in a WCF service that acts as a federation layer (of sorts?)

Can this method be extended for use by front ends created with other technologies (ASP .Net, MVC, Mobile, and so  on)?

This is a key point to resolve as we are architecting the solution.

Question by:jxbma
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    I want to determine at runtime which service endpoint to connect to, based on some user contextual data.
    Can you describe this "contextual data" more? I'm afraid it's still not quite clear how the dynamic behavior should be invoked.
    LVL 1

    Author Comment


    Thanks for getting back to me.

    The basic idea is I've got a front end WPF desktop based application.
    I want to have the front end be as independent as back end business logic as possible.
    It will merely be able to construct a request for data and then display the results within WPF panels.

    On the back end I've got a series of WCF services (ServiceA, ServiceB, ..)
    ServiceA - knows about WidgetAs and talks to ORACLE
    ServiceB - knows about WidgetBs and talks to SQL
    ServiceC - knows about WidgetCs and talks to Cassadra

    The interfaces these services will be based on will all pretty much look the same, or at least I can design it so they are.

    Services should be able to be added to the system dynamically (which we would keep track in MetaData) so it would not require a re-release of the front end WPF app. The front end should be able to query and find out what entities/services are available. It would expose access to these entities to users via menus, etc. It's cleaner if the front end doesn't have to know about and manage (potentially) a dynamic set of exposed services.

    Maybe I have a delegation/federation WCF service layer that the front end app talks to, and that federation layer talks to the actuall services. The issue I see with this that this becomes another "stop" in the communcation chain between the front and back ends. I don't think this will be so bad on static calls, but what when I want to stream data?

    I know in the MVC framework, there is a Dependency Resolver available. It sounds like it comes close(r) to what I'm looking for.  Is there a similar framework that will work or be extended to work with my WPF/WCF based application?

    So, just be clear, the scenario I'm  looking for is this:
    1) User logs into WPF app
    2) WPF queries backend to determine the entities/WCF services that are available
    3) WPF app exposes access to services through menus, toolbars, etc (from MetaData?)
    4) WPF app can call into desired entity to receive either static or stream results
    5) With this "dynamic" approach, it should be easy to add entities to metadata; services to back end which can be accessed through front end applications.

    We would really like to get as close to this model as possible.

    Thanks so much for your attention,
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Would you be able to use a RESTful architecture?
    LVL 18

    Accepted Solution

    LVL 1

    Author Comment

    No, a restful architecture would not work for me in this case.
    I will potentially have to deal with streaming data.


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now