Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the namespace url for in the Service Contract attribute

Tags:

.net

asp.net

wcf

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 its purpose?

like image 433
RJ. Avatar asked May 24 '10 14:05

RJ.


2 Answers

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)."

like image 100
James Avatar answered Sep 18 '22 23:09

James


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/).

like image 30
Daniel Dyson Avatar answered Sep 19 '22 23:09

Daniel Dyson