visual-studio ASMX:tempuri.org 应该被什么取代?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2402743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ASMX: What should tempuri.org be replaced with?
提问by JL.
Every new web service you create using visual studio comes with a predefined namespace like this:
您使用 Visual Studio 创建的每个新 Web 服务都带有一个预定义的命名空间,如下所示:
[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.
我的 Web 服务将在不同的客户端和不同的域上运行,因此我在开发过程中预先不知道域,而且我不想每次部署到新客户端时都必须编辑此文件.
What exactly should the value of Namespace be? It seems like a web address, but that doesn't make sense to me.
Namespace 的值究竟应该是什么?它看起来像一个网址,但这对我来说没有意义。
回答by Jacob
It's kind of ironic but the best answer is under : http://tempuri.org/
这有点讽刺,但最好的答案是: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/":
每个 XML Web Service 都需要一个唯一的名称空间,以便客户端应用程序将它与 Web 上的其他服务区分开来。默认情况下,ASP.Net Web 服务为此使用http://tempuri.org/。虽然这适用于正在开发的 XML Web Services,但已发布的服务应该使用唯一的、永久的命名空间。
您的 XML Web Service 应该由您控制的命名空间标识。例如,您可以使用您公司的 Internet 域名作为命名空间的一部分。尽管许多名称空间看起来像 URL,但它们不需要指向 Web 上的实际资源。
对于使用 ASP.NET 创建的 XML Web Services,可以使用 WebService 特性的 Namespace 属性更改默认命名空间。WebService 特性应用于包含 XML Web Service 方法的类。下面是一个将命名空间设置为“ http://microsoft.com/webservices/”的代码示例:
C#
[WebService(Namespace="http://microsoft.com/webservices/")]
public class MyWebService {
// implementation
}
回答by TomTom
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".
它基本上用作模式的资源标识符。但除了作为“标准的一部分”之外,它似乎没有真正的用途。
回答by John Saunders
http://tempuri.orgis 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.
http://tempuri.org是“XML 命名空间”的一个示例。在这种情况下,它恰好是网页在 Web 上的位置,但一般来说,XML 命名空间只是 URI 形式的文本字符串。
XML namespaces are for the purpose of making the names of XML nodes unique. The canonical example is to make sure that your Bookelement and the Bookelement 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 withinthe company - the uniqueness of domain names makes sure there is no conflict among domain names.
XML 名称空间的目的是使 XML 节点的名称唯一。规范示例是确保您的Book元素和Book另一个服务的元素属于两种不同的类型,并且不会相互冲突。如果可能,这就是将您公司的域名用作命名空间的一部分的原因。您公司的域名将是唯一的。想必你可以控制所有使用你公司域名的命名空间,所以你的公司可以确保公司内部不存在冲突——域名的唯一性确保域名之间不存在冲突。

