简体   繁体   中英

Two sided WCF services communication

I'm using WCF.

I have two applications: "Main" and "Worker".

Sometimes application "Main" is giving task for "Worker". "Worker" is doing work and when work is done it gives result to "Main".

How should this communication be done?

I need to call Worker.AddTask(Task) from Main and Main.AddResult(Result) from Worker. Is there better way than setting up two Services?

Does every call to "Worker" eventually end with a result for "Main" to work with? If so, you might want to just have "Main" call "Worker" asynchronously, the "Main" can just wait for the results as then come back. See: http://msdn.microsoft.com/en-us/library/ms730059.aspx

This sounds classic for WCF's callbacks- it allows for two-way async communication between server and client (in your case, the server would be the 'worker', and the 'main' application would invoke its methods in order to start processing. When worker is done, it will invoke a callback on main.)
LMGTFY :)

Assuming two applications are separate processes and communicating over services...

I think you may use netTcpBinding and Callback contracts

This requires two way communication between the two components. The first link I'm providing is the description in MSDN and the second link points to an implementation example. Enjoy.

MSDN Article

Example Link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM