0

While looking at a variety of examples and how-tos for creating WCF services I notice that some people decorate the interface code with attributes and others decorate the implmentation code. I understand decorating the interface with [ServiceContract] but where is the proper place for things like [WebGet] or [WebInvoke] or [AspNetCompatibilityRequirements]?

2 Answers 2

2

Most attributes' proper location is not up the developer, but specified by the WCF documentation. See the examples in these pages for proper attribute usage.

WebGet - interface, operation contract: http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webgetattribute.aspx

WebInvoke - interface, operation contract: http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webinvokeattribute.aspx

AspNetCompatibilityRequirements - service implementation: http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsattribute.aspx

Sign up to request clarification or add additional context in comments.

Comments

2

Since you are coding the class definition, it's best to place them in the same file as the class implementing them. Putting them on the interface makes it hard to remember how the method is to be used. With it right on the class and method implementations, you can't forget!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.