WebServiceAttribute.Namespace プロパティ
定義
XML Web サービスで使用する既定の XML 名前空間を取得または設定します。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
プロパティ値
XML Web サービスで使用する既定の XML 名前空間。The default XML namespace to use for the XML Web service. 既定値は DefaultNamespace プロパティで指定します。The default is specified in the DefaultNamespace property.
例
次の例では、をに設定し、を Namespace http://www.contoso.com
Action SoapDocumentMethodAttribute XML Web サービスメソッドに追加することによって、プロパティの名前空間をオーバーライドし Time
ます。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
注釈
XML 名前空間は、Uniform Resource Identifier (URI) で識別される XML ドキュメント内に名前を作成する方法を提供します。XML namespaces offer a way to create names in an XML document that are identified by a Uniform Resource Identifier (URI). XML 名前空間を使用すると、XML ドキュメント内の要素または属性を一意に識別できます。By using XML namespaces you can uniquely identify elements or attributes in a XML document. XML Web サービスのサービスの説明は XML で定義されており、特に Web サービス記述言語 (WSDL) で定義されています。The service description for a XML Web service is defined in XML, specifically in Web Services Description Language (WSDL).
Xml Web サービスのサービスの説明内では、は、xml Namespace web サービスに直接関連する xml 要素の既定の名前空間として使用されます。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. たとえば、XML Web サービスとその XML Web サービスメソッドの名前は、プロパティで指定された名前空間に関連し Namespace
ます。For example, the name of the XML Web service and its XML Web service methods pertain to the namespace specified in the Namespace
property. WSDL に固有の要素は、名前空間に関連し http://schemas.xmlsoap.org/wsdl/ ます。Elements that are specific to WSDL pertain to the http://schemas.xmlsoap.org/wsdl/ namespace.
SOAP を使用して xml Web サービスを呼び出す XML Web サービスクライアントでは、必要に応じてまたはを追加して SoapDocumentMethodAttribute SoapRpcMethodAttribute xml web サービスメソッドを呼び出すことができます。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. クライアントが ASP.NET を使用して作成された XML Web サービスを呼び出す場合、 RequestNamespace 、、およびの各 ResponseNamespace Action プロパティは、既定ではプロパティから派生し Namespace ます。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. たとえば、の XML Web サービスメソッド名とのプロパティを指定した場合、 Time
Namespace
http://www.contoso.com/
Action
プロパティは http://www.contoso.com/Time
既定でになります。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. XML Web サービスメソッドの、、およびの既定の設定を変更するには、 RequestNamespace
ResponseNamespace
Action
SoapDocumentMethodAttribute xml web サービスメソッドにを追加します。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.
注意
XML 名前空間は、Windows SDK の観点から、クラスが存在する名前空間とは異なります。An XML namespace is different from the namespace the class resides in, in terms of the Windows SDK. クラスの名前空間を指定する方法については、「C# で作成する場合の名前空間キーワード」を参照してください。To specify the namespace for the class, see Namespace Keywords if you writing in C#.