C# Web 应用程序动态调用来自第 3 方的 Web 服务

C# web application dynamically calling web services from 3rd party

我的 C# Web 应用程序应该调用第 3 方提供的 Web 服务。调用哪个 Web 服务只有在 运行 时间检测到提供程序时才知道。 例如:

Supplier #1 => client.ReceiveOrder(string orderNumber)

Supplier #2 => client.OrderReceiver(int OrderId)

Supplier #3 => client.GetOrderFromOutsideWorld(int OrderId, string OrderNumber)

所以基本上只有在收到订单后,应用程序才会知道调用哪个客户端以及公开哪些方法。

关于如何实现这一点的任何提示?要遵循的最佳做法?

提前致谢!

您可以通过实施 Strategy Pattern 来实现此目的。您必须定义不同客户端遵守的接口。