简体   繁体   English

为什么WCF服务函数需要OperationContract属性?

[英]Why is the OperationContract attribute required in a WCF service function?

为什么WCF服务函数需要OperationContract属性?

The OperationContact attribute explicitly declares that a method is an operation on a ServiceContract. OperationContact属性显式声明方法是ServiceContract上的操作。

Why is it required? 为什么需要它? The main reason is that most of WCF is opt-in and this is no different. 主要原因是大部分WCF都是选择加入,这也不例外。 WCF does not assume that simply because a method is part of an interface that you want to expose that method as a service operation. WCF并不认为这仅仅是因为方法是要将该方法公开为服务操作的接口的一部分。 It is left to the programmer to decide (and explicitly indicate) what they want to expose. 由程序员决定(并明确指出)他们想要公开的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM