在 WCF 服务中实现的共享接口 [英] Sharing Interfaces that are implemented in WCF Service
问题描述
我有 wcf 网络服务.Serice 当然实现了带有 ServiceContract 属性的接口.它还实现了另一个没有 ServiceContract 属性并存储在外部 dll 中的接口.当我生成代理时,我没有在代理对象中实现第二个接口.有没有办法让 svcutil 生成实现它的代理,或者我需要手动添加该代码?
I have wcf web service. Serice of course implements insterface with ServiceContract attribute. It also implements another interface that does not have ServiceContract attribute and is stored in external dll. When I generate proxy than I do not get that second interface implemented in proxy object. Is there any way to make svcutil to generate proxy that implements it or I need to add that code manually?
问候
推荐答案
那是不可能的.实现会是什么样子?它应该只是从原始类中复制粘贴实现吗?如果要将方法公开为 Web 服务,则必须将它们放在具有 ServiceContract
属性的类或接口中.
That is impossible. What would the implementation look like? Should it just copy-paste the implementation from the original class? If you want to expose methods as web services, you must put them in a class or interface with the ServiceContract
attribute.
假设原始服务类如下所示:
Suppose the original service class looks like this:
public class MyService : IServiceContract, IOtherInterface
{
...
public ObjectFromServiceAssembly MethodFromOtherInterface()
{
Console.WriteLine("Create instance of some object.");
return new ObjectFromServiceAssembly();
}
}
MethodFromOtherInterface
在生成的代理端看起来如何?它不能简单地从服务端复制您的实现.
How would MethodFromOtherInterface
look on the generated proxy side? It can't simply copy your implementation from the service side.
这篇关于在 WCF 服务中实现的共享接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!