为什么WCF服务功能中需要OperationContract属性? [英] Why OperationContract attribute required in WCF service function?

查看:508
本文介绍了为什么WCF服务功能中需要OperationContract属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么WCF服务功能需要OperationContract 属性?

例如

Why OperationContract attribute required in WCF service function?

e.g

[OperationContract]
public void DoWork()
{
    // Add your operation implementation here
    return;
}

// Add more operations here and mark them with [OperationContract]

推荐答案

您可能想开始阅读有关WCF的一些书籍.
这是一个非常基本的阅读 [
You might want to start reading some books on WCF.
Here is a very basic read[^] that should give you some idea.
As this msdn link suggests, the OperationContractAttribute attribute declares that a method is an operation in a service contract.


表示方法定义了一个操作,该操作是Windows Communication Foundation(WCF)应用程序中服务合同的一部分.

OperationContractAttribute属性可控制操作的结构以及元数据中表示的值:

动作 属性指定了唯一标识此操作的动作. WCF根据其操作将请求消息调度到方法.

AsyncPattern 属性表示该操作已实现,或可以使用Begin/End方法对异步调用.

HasProtectionLevel 属性指示是否已明确设置ProtectionLevel属性.

IsOneWay 属性表示该操作仅包含一条输入消息.该操作没有关联的输出消息.

IsInitiating 属性指定该操作是否可以作为会话中的初始操作.

IsTerminate 属性指定操作完成后WCF是否尝试终止当前会话.

ProtectionLevel 属性指定操作在运行时所需的消息级安全性.

ReplyAction 属性为操作指定回复消息的操作
Indicates that a method defines an operation that is part of a service contract in a Windows Communication Foundation (WCF) application.

the OperationContractAttribute properties to control the structure of the operation and the values expressed in metadata:

The Action property specifies the action that uniquely identifies this operation. WCF dispatches request messages to methods based on their action.

The AsyncPattern property indicates that the operation is implemented or can be called asynchronously using a Begin/End method pair.

The HasProtectionLevel property indicates whether the ProtectionLevel property has been explicitly set.

The IsOneWay property indicates that the operation only consists of a single input message. The operation has no associated output message.

The IsInitiating property specifies whether this operation can be the initial operation in a session.

The IsTerminating property specifies whether WCF attempts to terminate the current session after the operation completes.

The ProtectionLevel property specifies the message-level security that an operation requires at run time.

The ReplyAction property specifies the action of the reply message for the operation


,因为网络上的操作协定序列化方法.
没有属性方法的客户端应用程序将无法访问
because operation contract serialize method on network.
without attribute method can''t access on client application


这篇关于为什么WCF服务功能中需要OperationContract属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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