OSH
OSH

Reputation: 2937

can a WCF service consume it's own service?

I was wondering if this is possible: I want to create a set of servers that communicate with each other. The servers would be similar to each other (not a master - slave scenario). Is it possible to do this using WCF? If this is possible, I would appreciate a nudge in the right direction. (a good example or the right keywords to search for in google)

Thanks,

Upvotes: 2

Views: 1317

Answers (2)

Jens H
Jens H

Reputation: 4632

Yes, this a possible scenario.

However, instead of calling the service API directly I suggest to consider sending messages between the services, like the Microsoft Message Queue (MSMQ).

This decouples the several service instances from each other and reduces the need for dependencies of Service Reference (for example). The services would not need to know much of each other.

As soon as a message arrives, it is handled by a designated handler method. As you always work with different service instances this way, you would not need to bother with any recursive calls that Oskar mentioned.

WCF can easiliy be configured to use MSMQ as the underlying transport medium and supports it out-of-the-box.

Some articles/ tutorials to get you started:

Upvotes: 3

Oskar Kjellin
Oskar Kjellin

Reputation: 21880

Yes, it can. Just get the WSDL and then generate the class. It does not detect that it is "the same service".

Beware of infinite recursion though. I.E. a method calling itself, thus creating a loop and never terminating it.

Upvotes: 6

Related Questions