![]() |
Platforms, Frameworks & Libraries »
Windows Communication Foundation »
General
Advanced
License: The Code Project Open License (CPOL)
Integrating WCF ServicesBy taufufahThis article describes how WCF services can be loaded on-the-fly (without prior knowledge of the services’ contracts), setting its parameters and sequencing their invocation. |
C# (C# 3.0), Windows, Win32, Visual Studio (VS2005), WCF, WinForms, Architect, Dev, Design
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
The basic concept that this article is trying to present is how to subscribe to WCF services on-the-fly without prior knowledge of the services’ contract definitions. Once these services are loaded, user could then select desired operations from these services to be invoked sequentially through a simple sequencer. User could also set value for any parameters of a certain operation. With such concept, services located independently at different locations could be integrated to form a larger scale solution.
The sample project made references to the following great works:
Dynamic Programming with WCF by Vipul ModiA General Fast Method Invoker by LuyanThe concept is really pretty simple. There are services hosted somewhere ready to be subscribed. These are just ordinary WCF services. The client application can load these services by requiring user to key in the desired service’s URL. For the sample project, a service called ExampleService is hosted at the following URL.
http://localhost:8080/WcfSamples/DynamicProxy
public class ExampleService : IWorkWithIntrinsic
{
#region IWorkWithIntrinsic Members
public void WorkWithIntegers(int first, int second)
{
Console.WriteLine("IWorkWithIntrinsic.WorkWithIntegers was called.");
Console.WriteLine("\t1st Integer: " + first);
Console.WriteLine("\t2nd Integer: " + second);
}
public string WorkWithString(string myString)
{
Console.WriteLine("IWorkWithIntrinsic.WorkWithString was called.");
Console.WriteLine("\tString: " + myString);
return myString + " returned from server.";
}
public double WorkWithDouble(double myDouble)
{
Console.WriteLine("IWorkWithIntrinsic.WorkWithDouble was called.");
Console.WriteLine("\tDouble: " + myDouble);
return myDouble + 1.0;
}
#endregion
}
User could load (subscribe) a service by going for File, Load Service. The following dialog box will greet the user. User should check the Load All Contracts check box and click Ok.
All loaded services (proxies) will appear in a tree view. User can then choose desired operations to be added to the sequencer by performing a right click on the operation node and choose Add Operation. This is shown in the following diagram.
Finally, user can click on the Play button to execute all
selected operations.
The following screen shot depicts the sequence of events that have taken place on the server side.
Integrator.Framework.DynamicProxyModel – A project that made
dynamic proxy creation possible. Almost everything here are taken from the
great works by Vipul Modi as described above.
Integrator.Framework.ServiceManagerModel – A project that
manages all loaded proxies and its operations and parameters.
Integrator.Framework.Sequencer – Consists of the sequencer
component.
Integrator.Framework.TestServer – Service Host Application
Integrator.UI.Shell – CAB Shell that host all UI components.
Integrator.UI.Sequencer – UI that host the sequencer.
Integrator.UI.LoadedServices – UI that host all loaded
proxies.
Integrator.UI.ParameterEditor – UI that host the parameter
editor.
Integrator.UI.Common – Consists of constants and event
arguments for all UI components.
Set Integrator.Framework.TestServer as active project and
execute it by pressing Alt-F5 from Visual Studio 2005.
Set Integrator.UI.Shell as active project and execute the
project by pressing F5 from Visual Studio 2005. Perform the steps as described
in Description on Basic Concept section above.
The following items are planned features for the project
that I can’t find time to get them implemented.
Event Broker System – to work with the sequencer in order to
construct a Publish\Subscribe model. The idea is, once an operation is completed, its return parameter can be used as input parameter to another operation.
Handling complex parameters - currently, code to handle complex parameter have been included but only half-baked.
Serving UI - Having the service to serve its own UI (possibly XAML).
| You must Sign In to use this message board. | |||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 24 Apr 2008 Editor: |
Copyright 2008 by taufufah Everything else Copyright © CodeProject, 1999-2009 Web18 | Advertise on the Code Project |