简体   繁体   中英

SOAP - namespace, what is this used for?

SOAP Web服务中使用的命名空间是什么?

From http://tempuri.org/ :

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.

Say company A and B both create a service with methods of the same signature. In order to differentiate between them you can add a namespace. That would make them different from a client's perspective, meaning you couldn't use the wsdl(proxy classes) from one on the other and vice verse.

It's considered good practice to use a unique namespace for your services. Typically your company name/domain or similar, instead of the default tempuri.org .

Namespace is an XML concept. Suppose you have an XML document about books which have an element <title> , and a document about persons which have an element <title> . Both <title> elements have a different conceptual meaning, even though they have the same name. If you would merge the documents, you would not see the difference between the two.

That is where the namespace comes in. The full name of an element consists of the namespace and the element name, but the namespace is often abbreviated or omitted.

XML lets you use define shorter words for namespaces. For example, you can define that b=http://www.books.info/my_books and after that you can use <b:title> if you mean the title from that namespace.

我认为这个System.Web.Services.Protocols

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM