Service Cloud - dynamic calls to a cloud of WCF services

For awhile, myself and another developer have been trying to build a working prototype of an idea he proposed for a Service Cloud. Essentially the Service Cloud is a collection of WCF services hosted on a number of servers and environments that can all communicate with one another via a common interface. An "application" would then be built by orchestrating these services together.

Instead of the application adding service references for each of the services it needs -- it would simply send a request to the "Gateway" service and it would figure out the rest. It would call the other services.

Finally, when the execution is complete and your request has bounced all over the cloud, you get a response that many services have built together.

I finally was able to create a working prototype (albeit completely contrived).

The Service Cloud prototype is available on GitHub, see: http://github.com/xeb/ServiceCloud.

Client
The client is simple. The client adds a WCF Service Reference to the Gateway service and calls the Gateway's service Execute method. The prototype requires that the full Endpoint Address of each service in the cloud be specified -- but this could easily be added to the Host (or better yet -- a service in the Host!).


// Start up the Cloud Gateway!
var cloud = new CloudServiceClient();

// Formulate our Request and get a Response from the Gateway
var response = cloud.Execute(new Request
{
Argument = 15,
Services = new[]
{
new ServiceCall { Name = "Decrementer",
Address = "http://localhost:8731/Design_Time_Addresses/ServiceCloud.Services/Decrementer/" },
new ServiceCall { Name = "Incrementer",
Address = "http://localhost:8731/Design_Time_Addresses/ServiceCloud.Services/Incrementer/" },
new ServiceCall { Name = "Incrementer",
Address = "http://localhost:8731/Design_Time_Addresses/ServiceCloud.Services/Incrementer/" },
},
});

cloud.Close();


Now the Response we get back has a ReturnObject property that will be the result of our 3 service calls. Can you guess what the result will be?



Pretty straight forward huh? Check out the
Service Cloud Host at github for more details on how to make the magic happen.

Now imagine a Request to the Cloud with something like the following & I think you will see the potential.


// Formulate our Request and get a Response from the Gateway
var response = cloud.Execute(new Request
{
Argument = new Person("Mark Kockerbeck") { Message = "I see you" },
Services = new[]
{
new ServiceCall { Name = "FindAddress",
Address = "http://epicapp.com/findaddress" },

new ServiceCall { Name = "FindEmail",
Address = "http://epicapp.com/findemail" },

new ServiceCall { Name = "FindTwitter",
Address = "http://epicapp.com/findtwitter" },

new ServiceCall { Name = "SendTwitterMessage",
Address = "http://epicapp.com/sendmessage/" },

new ServiceCall { Name = "SendEmail",
Address = "http://epicapp.com/sendmessage/" },

new ServiceCall { Name = "SendDirectMail",
Address = "http://epicapp.com/sendmessage/" },
},
});


A scary example but the potential for many applications exists.

Comments

Popular posts from this blog

Require comment / message on all SVN commits for Visual SVN Server

Fluent NHibernate - Incorrect syntax near the keyword 'Group'

Deleting Cookies (or Managing Cookie Domains) in ASP.NET