[Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2012-09-06
Medium Priority
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
  • 2
  • 2
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38375033
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.

Author Comment

ID: 38377633

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 75

Expert Comment

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

Accepted Solution

DarrenD earned 2000 total points
ID: 38382212

Author Comment

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


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 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