如何设计和实现一个简单的 WCF 服务中继? [英] How to design and implement a simple WCF service relay?

查看:10
本文介绍了如何设计和实现一个简单的 WCF 服务中继?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设计一个使用 WCF 作为实现框架的简单的面向服务的架构.少数应用程序使用了一些服务.这些服务大多在内部使用,因此一个基本的身份验证和授权方案(例如基于 Windows)就足够了.

We are in the process of designing a simple service-oriented architecture using WCF as the implementation framework. There are a handful of services that a few applications use. These services are mostly used internally, so a basic authentication and authorization scheme (such as Windows-based) is enough.

但是,我们希望向某些业务合作伙伴公开一些服务.他们可以访问的服务集取决于合同.一种标准架构.

We want, however, expose some of the services to some business partners. The set of services they have access to depend on the contract. Kind of a standard architecture.

我认为我们可以实现一个服务网关,它对请求进行身份验证并将它们中继到正确的内部服务端点(这类似于简单的 ESB),因此我们可以集中身份验证/授权代码并公开一个世界的单一端点.我查看了一些可用的 ESB 工具包,但对于此目的而言,它们似乎过于复杂.我们不需要集成很多不同的服务,只需要将其中的一些服务公开到互联网上.

I think we can implement a service gateway which authenticates the requests and relays them to the correct internal service endpoint (this resembles simple ESB), so we can centralize the authentication/authorization code and expose one single endpoint to the world. I looked at some available ESB toolkits, but they seem way too complex for this purpose. We do not need to integrate a lot of different services, but just to expose some of them to the Internet.

如何在 WCF 中设计和实现这样的中继/路由器,同时保持非常简单?我读过Inside Windows Communication Foundation,这是一本好书,但我对如何开始还没有足够的信心.

How can I design and implement such a relay/router in WCF, keeping it very simple? I have read Inside Windows Communication Foundation, which is a good book, but I'm still not confident enough on how to begin.

推荐答案

我做过一些与此非常相似的事情.您可以做的是通过单个操作公开一个端点.

I have done something very similar to this. What you can do is expose an endpoint with a single operation.

该操作看起来像

[OperationContract(Namespace="www.fu.com", Action="*")]
void CallThis(Message msg);

让您的客户使用一个代理,该代理是为他们打算调用他们想要的操作的服务而设计的.然后让他们更改配置以指向您的端点/服务.CallThis"方法将接受任何操作,无论其签名如何.Message 参数是 WCF 消息.

Have your clients use a proxy that is intended for the service they intended to calling the operation they want. Then have them change the configuration to point to your endpoint/service. The "CallThis" method will accept any operation, regardless of its signature. The Message parameter is the WCF Message.

做你需要做的事情来确定事情应该去哪里,但是你需要改变To"去你的内部端点.

Do what you need to do to determine where things are supposed to go, but you will need to change the "To" to go to your internal endpoint.

我实际上有一个完整的实现,所以如果您有任何问题,请告诉我.

I actually have a full implementation of this, so if you have questions, let me know.

乔.

这篇关于如何设计和实现一个简单的 WCF 服务中继?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆