views:

124

answers:

2

In the [Service Contract(Namespace="http://myuri.org/Simple")] what is the Namespace for? I have done WCF services and never included this. What is it's purpose?

+1  A: 

D3eclaring a namespace is particularly important if you are in a big organisation such as a bank that might have multiple implementations of a webservice method such as GetDerivativeProduct().

From the MSDN docs:

It is highly recommended that this default namespace, which is http://tempuri.org, be changed before the XML Web service is made publicly consumable. This is important because the XML Web service must be distinguished from other XML Web services that might inadvertently use the namespace as the default (http://tempuri.org/).

Daniel Dyson
+2  A: 

The namespace property is really an XML term. It allows you to maintain uniqueness with elements (similar to what .NET does with namespaces). So you can have multiple elements of the same tag name but they are completely different as long as they have different namespaces. The Namespace property of the ServiceContractAttribute class according to MSDN refers to the following:

"Gets or sets the namespace of the <portType> element in Web Services Description Language (WSDL)."

James
+1 for MSDN link and "uniqueness" word. It's important to pay attention, that the Namespace property is also applied to WebServices (not only on WCF with ServiceContractAttribute): **[WebService(Namespace = "http://organization.service/")]**
Erup