gpt4 book ai didi

visual-studio - ASMX:tempuri.org 应该被什么取代?

转载 作者:行者123 更新时间:2023-12-04 05:57:50 26 4
gpt4 key购买 nike

您使用 Visual Studio 创建的每个新 Web 服务都带有一个预定义的命名空间,如下所示:

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

我的 Web 服务将在不同的客户端和不同的域上运行,因此我在开发过程中预先不知道域,而且我不想每次部署到新客户端时都必须编辑此文件.

Namespace 的值究竟应该是什么?它看起来像一个网址,但这对我来说没有意义。

最佳答案

这有点讽刺,但最好的答案是: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.

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
}

关于visual-studio - ASMX:tempuri.org 应该被什么取代?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2402743/

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