简体   繁体   中英

WCF [operationcontract] can be ignored when you use REST's webinvoke or webget?

[WebInvoke(UriTemplate = "/GetContent", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public List<Content> GetContent(string path) {
        return Utility.GetContent(path);
    }

[OperationContract]
[WebInvoke(UriTemplate = "/GetContent", RequestFormat = WebMessageFormat.Json,     BodyStyle = WebMessageBodyStyle.Wrapped)]
public List<Content> GetContent(string path) {
    return Utility.GetContent(path);
}

Do these two methods function the same way or do they do anything different? Looks like they both work for me..

The OperationContractAttribute attribute declares that a method is an operation in a service contract. Only methods attributed with the OperationContractAttribute are exposed as service operations. A service contract without any methods marked with the OperationContractAttribute exposes no operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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