views:

209

answers:

3

Every new web service you create using visual studio comes with a predefined namespace like this:

[WebService(Namespace = "http://tempuri.org/")]

My web service will run at different clients, and on different domains, so because of this I don't know the domain upfront during development, also I don't want to have to edit this file, each time I deploy to a new client.

What exactly should the value of Namespace be? It seems like a web address, but that doesn't make sense to me.

Please explain.

Thanks

+2  A: 

Put in your domain, as developer ;)

it is basically used as resource identifier to schemata. But it seems to ahve no real use except being "part of the standard".

TomTom
Do I need to have the http:// bit - or can I just name it anything?
JL
+2  A: 

It's kind of ironic but the best answer is under : http://tempuri.org/

quote

Each XML Web Service needs a unique namespace in order for client applications to distinguish it from other services on the Web. By default, ASP.Net Web Services use http://tempuri.org/ for this purpose. While this suitable for XML Web Services under development, published services should use a unique, permanent namespace.

Your XML Web Service should be identified by a namespace that you control. For example, you can use your company's Internet domain name as part of the namespace. Although many namespaces look like URLs, they need not point to actual resources on the Web.

For XML Web Services creating using ASP.NET, the default namespace can be changed using the WebService attribute's Namespace property. The WebService attribute is applied to the class that contains the XML Web Service methods. Below is a code example that sets the namespace to "http://microsoft.com/webservices/":

C#
[WebService(Namespace="http://microsoft.com/webservices/")]
public class MyWebService {
    // implementation
}
Jacob
+1 and accepted answer - Lol - excuse the humor, but what if your company is too poor to afford a domain name ? :) JK
JL
A: 

http://tempuri.org is an example of an "XML Namespace". In this case, it happens to be the location of a page on the Web, but in general, an XML Namespace is just a text string in the form of a URI.

XML namespaces are for the purpose of making the names of XML nodes unique. The canonical example is to make sure that your Book element and the Book element of another service are of two different types and do not conflict with each other. That's the reason to use your company's domain name as part of the namespace, if possible. Your company's domain name will be unique. Presumably you are in control of all namespaces that use your company's domain name, so your company can make sure that there are no conflicts within the company - the uniqueness of domain names makes sure there is no conflict among domain names.

John Saunders