Communicate between 2 WCF services

前端 未结 2 1651
谎友^
谎友^ 2021-01-27 00:48

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

相关标签:
2条回答
  • 2021-01-27 01:40

    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.

    0 讨论(0)
  • 2021-01-27 01:46

    Easy! With WCF!

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

    0 讨论(0)
提交回复
热议问题