In designing my service, I decided that I wanted to customize the namespaces that appeared in the resulting WSDL.
For the DataContracts, i came across the ContractNamespace attribute which seemed a nice shortcut alternative to setting the same namespace explicitly for every DataContract. My initial attempt looked like this:
[assembly:ContractNamespace("http://types.mycompany.com/2010/08/03")]
namespace MyCompany.MyContracts
{
[DataContract]
//...multiple datacontract classes here
}
To my surprise, this did not work. After much tinkering, I was only successful when I finally set the ClrNamespace property of the attribute equal to my CLR namespace (MyCompany.MyContracts in the example). So something like this
[assembly:ContractNamespace("http://types.mycompany.com/2010/08/03",
ClrNamespace="MyCompany.MyContracts")]
My question is: why did this not work the first way? My expectation was that by not specifying a CLR namepsace, this attribute would affect all datacontracts assembly-wide.