Επεξεργασία

Κοινή χρήση μέσω


WebServiceAttribute.Name Property

Definition

Gets or sets the name of the XML Web service.

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

Property Value

The name for the XML Web service. Default value is the name of the class implementing the XML Web service.

Examples

The following example sets Name of the XML Web service to 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

Remarks

The Service Description is generated when a user navigates to the URL for the XML Web service and supplies a query string of ?WSDL. Within the Service Description, the Name property identifies the local part of the XML qualified name for the XML Web service. The Name property is also used to display the name of the XML Web service on the Service help page. The Service help page is displayed when a prospective consumer navigates to the.asmx page for the XML Web service without specifying an XML Web service method name and its parameters.

An XML qualified name is used to disambiguate elements with the same name with an XML document. An XML qualified name consists of the following two parts separated by a colon: namespace or a prefix associated with a namespace and local part. The namespace consists of a URI reference and for the purposes of the Service Description, is the value of the Namespace property. In general, a prefix, which acts like an alias to an URI, is associated with the namespace, so that all subsequent XML qualified names using the namespace can use the shortened prefix. The local part is a string beginning with a letter or underscore containing no spaces. Therefore, the XML qualified name identifying a XML Web service in the Service Description is in the following format:

Namespace : Name

For more information on XML qualified names, see Namespaces in XML 1.0.

Applies to

See also