WCF 多端点和 IServices

发布于 2024-11-10 06:26:55 字数 433 浏览 0 评论 0原文

我只是想掌握使用 WCF,并且我想知道是否有人可以告诉我我对端点的想法是否正确。

我一直在浏览msdn上的视频,现在我正在思考如何配置WCF服务。情况是,如果我有多个 IService,例如,我有一个 IThis 和 IThat,并且客户端需要访问这两个服务(注意:他们将使用 net.tcp),

  • IThis 处理数据库查询,

  • IThat 处理独立于数据库的计算,

我假设我必须为 IThis 和 IThat 定义单独的端点,它们在客户单独。或者我会创建一个在客户端中引用的整体 IThisAndThat 服务并包含两者的功能吗?

或者是使用多个 IService 开发和处理 WCF 服务的其他方法吗?当我问你能否定义 tcp 或仅 http 的基地址?

~谢谢大家,任何帮助或指点都会很棒。

I am just trying to get to grips with using WCF, and I am wandering if someone could tell me if I have the right idea with endpoints.

I have been working through the videos on msdn, and now I am wandering about the way to configure WCF Service. The scenario is if I have multiple IServices, e.g. such that I have an IThis and IThat, and the client needs the access both (note: they will be using net.tcp),

  • IThis handles database querying and,

  • IThat handles calculations independent of the database,

I assume that I have to define separate Endpoints for IThis and IThat, that are referenced in the client separately. Or would I create an overall IThisAndThat Service that gets referenced in the client and contains the functionality for both??

Or is are the other ways for developing and handling WCF Services with multiple IServices? While I'm asking can you define base address for tcp or only http?

~Thanks all, any help or pointers would be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世俗缘 2024-11-17 06:26:55

我认为我必须定义
IThis 和的单独端点
IThat,在
客户端单独。或者我会创建
一个整体的 IThisAndThat 服务
在客户端中被引用并且
包含两者的功能??

您可以同时执行这两项操作:

  • 您可以创建一个单独的服务实现类 - 一个用于 IThis,另一个用于 IThat
  • 或者您可以创建一个同时实现 IThisIThat 的服务实现类

。这种选择完全取决于您。

对于您拥有的每个服务实现类,您可以定义您希望拥有的任意数量的端点。因此,如果您有一个实现 IThisThisService,您可以为其定义一个 HTTP 和一个 TCP 端点,并且您还有一个实现 ThatService IThat 您为其定义 TCP 端点。这完全取决于你。

但是:您只能为每个服务实现类定义端点 - 如果您有一个实现两个服务契约的 ThisAndThatService,则无法定义 3 个端点对于 IThis 和两个不同的 IThat - 您定义的端点是针对每个服务实现类的。

当我问你能否定义基础时
TCP 地址还是仅 http 地址?

是的,绝对的 - 您可以为每个不同的寻址方案(http、net.tcp、net.msmq、net.pipe 等)定义基地址。

I assume that I have to define
separate Endpoints for IThis and
IThat, that are referenced in the
client separately. Or would I create
an overall IThisAndThat Service that
gets referenced in the client and
contains the functionality for both??

You can do both:

  • you can create a separate service implementation class - one for IThis, another one for IThat
  • or you can create a single service implememtation class that implements both IThis and IThat

That choice is entirely up to you.

For every service implementation class that you have, you can define any number of endpoints you wish to have. So if you have an ThisService implementing IThis, you can define a HTTP and a TCP endpoint for that, and you also have a ThatService that implements IThat for which you define a TCP endpoint. That's totally up to you.

BUT: you can only define your endpoints for each service implementation class - if you have a ThisAndThatService implementing both service contracts, you cannot define 3 endpoints for IThis and two different ones for IThat - the endpoints you define are per service implementation class.

While I'm asking can you define base
address for tcp or only http?

Yes, absolutely - you can define a base address for each of the various addressing schemes (http, net.tcp, net.msmq, net.pipe and so forth).

残疾 2024-11-17 06:26:55

一些基础知识:

每项服务都有一个或多个端点。端点特定于其相关服务,即每个端点只能属于一个服务并且不能在服务之间共享。

端点定义了服务的入口点——它包括客户端可以使用的地址、绑定和契约。

不同的端点必须具有不同的地址,并且可以具有不同的绑定和契约(即它们不必)。通常,不同的端点具有不同的绑定——即传输协议。如果特定客户只能访问某些操作,他们可以签订不同的合同。

最后,您的服务必须实现其各个端点公开的所有契约。

这是一个非常简洁明了的 MSDN 页面,它描述了这些概念。 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/9f4391e9-8b9f-4181-a081-860d42b992a9/

有很多关于 WCF 的信息网络,还有很多东西要学。最好看一些专注于您想要做的事情的教程或指南。

Some basics:

Each service has one or more endpoints. The endpoints are specific to their relevant service, i.e. each endpoint can only belong to one service and cannot be shared between services.

An endpoint defines an entrypoint to the service - it includes an address, binding and contract that can be utilized by a client.

Different endpoints must have different addresses, and can have different bindings and contracts (i.e. they do not have to). Typically, different endpoints have different bindings - that is, transport protocol. They can have different contracts if particular clients are only supposed to have access to certain operations.

Finally, your service must implement all of the contracts that its various endpoints expose.

Here's a very concise and straightforward MSDN page which describes these concepts. http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/9f4391e9-8b9f-4181-a081-860d42b992a9/

There's a lot of information on WCF on the web, and there's a lot to learn. Best to look at some tutorials or guides which focus on what you are trying to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文