来自单个 WCF 服务的多个接口? [英] Multiple interfaces from a single WCF service?

查看:27
本文介绍了来自单个 WCF 服务的多个接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单个 WCF 服务能否提供多个接口,如果可以,您将如何在 app.config 中表达?

Can a single WCF service offer multiple interfaces, and if so how would you express this in app.config?

我的意思是一种服务,在一个端点上提供多个接口.

I mean one services offering several Interfaces on one endpoint.

推荐答案

首先你需要清楚什么是服务.您是指单个端点还是同一主机中的多个端点?

First you need to be clear what a service is. Do you mean a single endpoint, or multiple endpoints in the same host?

假设您的意思是单个端点,那么可以,但需要做一些工作.一个端点只能实现一个接口;所以你需要做的就是将你想要实现的所有接口组合成一个接口

Assuming you mean a single endpoint, then yes, but with a little work. An endpoint can only implement a single interface; so what you need to do is combine all the interfaces you want to implement into a single interface

public interface IMyInterface : IInterface1, IInterface2

然后在你的实现类中实现它们.你不能做的是将多个接口和多个实现神奇地合并到一个端点中.

and then implement them all inside your implementation class. What you cannot do is have multiple interfaces and multiple implementations magically merge into a single endpoint.

这篇关于来自单个 WCF 服务的多个接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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