I understand I can apply several options to the ServiceContract (like Name, Namespace) attribute and for OperationContract (Action, ReplyAction)
The same goes to DataContract (Namespace) and DataMember (IsRequired, Name, Order)
How do I determine if I need to apply a particular option or not. What is the best practice/convention I should follow?
There’s no one “best practice” here. Just understand what all of the different arguments are used for.
Nameshould be specified if you want the “public” name of your service to be different from the actual class name (most people don’t change this). It’s similar for data contracts – use it if you want the name exposed over SOAP/MEX to be different from the property name you use internally.Namespaceis something you should change, otherwise it defaults totempuri.org– you should replace this with a namespace that’s relevant to your application.IsRequiredshould be specified if the type is nullable (i.e. astring) but the field is actually required as part of the contract (for example, a customer must have a name… that is a required field).Orderjust changes the order that properties appear in the metadata/XML; usually most people don’t bother with this unless it’s required for compatibility reasons.