I am implementing a .Net WCF service and I want to apply a namespace for future versioning. A coworker mentioned that I ought to apply several attributes to both the interface and the concrete implementation class for that interface, but it is not clear to me 1) if this is correct, and 2) assuming it is correct, why it would be important to apply the attributes in both places.
[ServiceContract]
[ServiceBehavior(Namespace = Constants.NameSpace1_0)]
[WebService(Namespace = Constants.NameSpace1_0, Name = "MyService1_0")]
[WebServiceBindingAttribute(ConformsTo = System.Web.Services.WsiProfiles.BasicProfile1_1, EmitConformanceClaims = true)]
public interface IMyService
{
[OperationContract]
[OperationContract(Name = "MyMethod", Action = Constants.NameSpace1_0 + "/IMyService/MyMethod")]
string MyMethod(string phrase);
}
public class MyServiceConcrete : IMyService
{
public string MyMethod(string phrase);
}
In this example, should I also apply the attributes that are applied to the interface to the concrete class (and its methods) that implements the MyService interface? Should I apply the same attributes in both places or just one of the places, and why? Thanks.