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


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.

jxbmaSoftware ConsultantAsked:
Who is Participating?
DarrenDConnect With a Mentor Commented:
käµfm³d 👽Commented:
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.
jxbmaSoftware ConsultantAuthor Commented:

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,
käµfm³d 👽Commented:
Would you be able to use a RESTful architecture?
jxbmaSoftware ConsultantAuthor Commented:
No, a restful architecture would not work for me in this case.
I will potentially have to deal with streaming data.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.