Communicate between 2 WCF services

自闭症网瘾萝莉.ら 提交于 2019-12-04 05:14:34

问题


How to communicate between 2 WCF services hosted on 2 different machines.


回答1:


Easy! With WCF!

Add a service reference to each of them pointing to the other and you're done.




回答2:


The question is a little vague, because it really depends on what you're looking to communicate between the two machines, and what binding you're using.

The first way I'm interpreting the question is that Service A needs to communicate with Service B and vice-versa. The simplest way is to have Service A be a client of Service B, and Service B be a client of Service A. When the host starts up each service it also opens the client proxy for communication. This would work regardless of the binding used.

The second way I'm interpreting the question is that Service A needs to be a client of Service B, but allow Service B to call back to Service A. Simply modifying the service contract to include callback contracts should suffice for this. Of course this wouldn't work for all bindings, especially not if you're using message queues.



来源:https://stackoverflow.com/questions/409373/communicate-between-2-wcf-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!