Link to home
Start Free TrialLog in
Avatar of jxbma
jxbmaFlag for United States of America

asked on

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

Hi:

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.

Thanks,
JohnB
Avatar of kaufmed
kaufmed
Flag of United States of America image

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.
Avatar of jxbma

ASKER

Hey:

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,
JohnB
Would you be able to use a RESTful architecture?
ASKER CERTIFIED SOLUTION
Avatar of Darren
Darren
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jxbma

ASKER

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

JB