WebServiceAttribute.Name 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 XML Web 服务的名称。
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
属性值
XML Web 服务的名称。 默认值是实现 XML Web 服务的类的名称。
示例
以下示例将 XML Web 服务集 Name 设置为 MyName。
<%@ WebService Language="C#" class= "ServerVariables"%>
using System.Web.Services;
[ WebService(Description="Server Variables",
Namespace="http://www.microsoft.com/",
Name="MyName")]
public class ServerVariables: WebService {
[ WebMethod(Description="Returns the time as stored on the Server",
EnableSession=false)]
public string Time() {
return Context.Timestamp.TimeOfDay.ToString();
}
}
<%@ WebService Language="VB" class= "ServerVariables"%>
Imports System.Web.Services
<WebService(Description := "Server Variables", _
Namespace := "http://www.microsoft.com/", _
Name := "MyName")> _
Public Class ServerVariables
Inherits WebService
<WebMethod(Description := "Returns the time as stored on the Server", _
EnableSession := False)> _
Public Function Time() As String
Return Context.Timestamp.TimeOfDay.ToString()
End Function
End Class
注解
当用户导航到 XML Web 服务的 URL 并提供查询字符串时,将生成服务说明?Wsdl。 在服务说明中,该 Name 属性标识 XML Web 服务的 XML 限定名称的本地部分。 该 Name 属性还用于在“服务帮助”页上显示 XML Web 服务的名称。 当潜在使用者导航到 XML Web 服务的 .asmx 页面而不指定 XML Web 服务方法名称和参数时,将显示“服务帮助”页。
XML 限定名称用于消除与 XML 文档同名的元素的歧义。 XML 限定名由冒号分隔的以下两个部分组成:命名空间或与命名空间和本地部件关联的前缀。 命名空间由 URI 引用组成,出于服务说明的目的,是属性的值 Namespace 。 通常,前缀(类似于 URI 的别名)与命名空间相关联,以便使用命名空间的所有后续 XML 限定名称都可以使用缩短的前缀。 本地部分是一个字符串,以字母或下划线开头,不含空格。 因此,在服务说明中标识 XML Web 服务的 XML 限定名称采用以下格式:
有关 XML 限定名称的详细信息,请参阅 XML 1.0 中的命名空间。