ElenaDBA ElenaDBA - 1 month ago 8
reST (reStructuredText) Question

REST vs SOAP WCF Service - is there a downside for using both

When developing my WCF Service I originally planned using REST but later found out it will be called using SOAP. I have decorate my methods with both SOAP

OperationalContract
and REST
WebInvoke
but created only SOAP endpoint.

public interface IMyService
{

[OperationContract]
[WebInvoke(UriTemplate = "GetData/{ID}/{Name}", Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
string GetData(string ID, string Name);

}


My question is what are the possible implications of using both
OperationalContract
and
WebInvoke
, if any? Are there downsides?

Should I keep it as it is, in case later I might need to add a REST endpoint? Or should I remove
WebInvoke
?

Answer

My question is what are the possible implications of using both OperationalContract and WebInvoke, if any? Are there downsides?

No, there are no downsides, other than you are adding code which may never be used.

Also, for your info, OperationContract is for all WCF operations, not just for SOAP operations. You need it for REST also.

Comments