对于Web HTTP编程模型来说,服务契约中作为操作的方法无须应用OperationContractAttribute特性,只需要根据需要应用WebGetAttribute与WebInvokeAttribute特性即可。前者针对GET HTTP方法,或者则针对其他HTTP方法。WebGetAttribute与WebInvokeAttribute的属性BodyStyle和IsBodyStyleSetExplicitly涉及到“Web消息主体风格”的话题。
1: [AttributeUsage(AttributeTargets.Method)]
class WebGetAttribute : Attribute, IOperationBehavior
3: {
//其他成员
public WebMessageBodyStyle BodyStyle { get; set; }
6: }
7:
8: [AttributeUsage(AttributeTargets.Method)]
class WebInvokeAttribute : Attribute, IOperationBehavior
10: {
//其他成员
public WebMessageBodyStyle BodyStyle { get; set; }
13: }