WebServiceAttribute.Namespace Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the default XML namespace to use for the XML Web service.
public:
property System::String ^ Namespace { System::String ^ get(); void set(System::String ^ value); };
public string Namespace { get; set; }
member this.Namespace : string with get, set
Public Property Namespace As String
Property Value
The default XML namespace to use for the XML Web service. The default is specified in the DefaultNamespace property.
Examples
The following example sets Namespace to http://www.contoso.com
and overrides that namespace for the Action property by adding a SoapDocumentMethodAttribute to the Time
XML Web service method.
<%@ WebService Language="C#" class= "ServerVariables"%>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
[ WebService(Description="Server Variables",
Namespace="http://www.contoso.com/")]
public class ServerVariables: WebService {
[ SoapDocumentMethod(Action="http://www.contoso.com/Time")]
[ 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
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Description := "Server Variables", _
Namespace := "http://www.contoso.com/")> _
Public Class ServerVariables
Inherits WebService
<SoapDocumentMethod(Action := "http://www.contoso.com/Time"), _
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
XML namespaces offer a way to create names in an XML document that are identified by a Uniform Resource Identifier (URI). By using XML namespaces you can uniquely identify elements or attributes in a XML document. The service description for a XML Web service is defined in XML, specifically in Web Services Description Language (WSDL).
Within the Service Description for an XML Web service, Namespace is used as the default namespace for XML elements directly pertaining to the XML Web service. For example, the name of the XML Web service and its XML Web service methods pertain to the namespace specified in the Namespace
property. Elements that are specific to WSDL pertain to the http://schemas.xmlsoap.org/wsdl/ namespace.
For XML Web service clients using SOAP to call an XML Web service, you can optionally add the SoapDocumentMethodAttribute or SoapRpcMethodAttribute to call an XML Web service method. If the client is calling an XML Web service created using ASP.NET, the RequestNamespace, ResponseNamespace and Action properties are all derived from the Namespace property by default. For instance, given an XML Web service method name of Time
and a Namespace
property of http://www.contoso.com/
, the Action
property is http://www.contoso.com/Time
by default. To change the default settings for RequestNamespace
, ResponseNamespace
, and Action
for an XML Web service method, you can add a SoapDocumentMethodAttribute to the XML Web service method.
Note
An XML namespace is different from the namespace the class resides in, in terms of the Windows SDK. To specify the namespace for the class, see Namespace Keywords if you writing in C#.
Applies to
See also
Tilbakemeldinger
https://aka.ms/ContentUserFeedback.
Kommer snart: Gjennom 2024 faser vi ut GitHub Issues som tilbakemeldingsmekanisme for innhold, og erstatter det med et nytt system for tilbakemeldinger. Hvis du vil ha mer informasjon, kan du se:Send inn og vis tilbakemelding for