gpt4 book ai didi

c# - [WebService(Namespace = "http://tempuri.org/")] 在哪里使用?

转载 作者:太空宇宙 更新时间:2023-11-03 18:14:27 24 4
gpt4 key购买 nike

我制作了一个返回国家名称的网络服务。我的网络服务返回的是

<ArrayOfString>
<string>Australia</string>
<string>USA</string>
<string>UK</string>
</ArrayOfString>

为什么我们有 [WebService(Namespace = "http://tempuri.org/")]

我读到它是在客户端区分节点。此 URL 也不是网络服务的位置。

它有实际用途吗?

最佳答案

Web 服务使用 namespace 将它们的类型与其他服务的类型区分开来。 http://tempuri.org/ 是一个临时的(因此得名)命名空间,在进入实时环境时应将其替换。通常它包含一个表示源的 URI(即您公司的网站 URL)加上一些其他指示符以将其与您组织中的其他服务区分开来(例如 http://www.haansi.org/Companies ).

来自 MSDN:

An XML Web service should change its default XML namespace before it is made public. Each XML Web service needs a unique XML namespace to identify it so that client applications can distinguish it from other services on the Web. http://tempuri.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace.

Your XML Web service should be identified by a XML namespace that you control. For example, you could use your company's Internet domain name as part of the XML namespace. Although many XML Web service XML namespaces look like URLs, they need not point to an actual resource on the Web. (XML Web service XML namespaces are URIs.) For XML Web services created using ASP.NET, the default XML namespace can be changed using Namespace property.

关于c# - [WebService(Namespace = "http://tempuri.org/")] 在哪里使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8935210/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com