SoapDocumentMethodAttribute クラス

定義

SoapDocumentMethodAttribute をメソッドに適用することにより、そのメソッドとの間で送受信される SOAP メッセージに Document 書式を適用することを指定できます。

public ref class SoapDocumentMethodAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class SoapDocumentMethodAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type SoapDocumentMethodAttribute = class
    inherit Attribute
Public NotInheritable Class SoapDocumentMethodAttribute
Inherits Attribute
継承
SoapDocumentMethodAttribute
属性

次のコード例では、XML Web サービス メソッドのメッセージ スタイルを にDocumentGetUserName設定します。 さらに、SOAP 要求と SOAP 応答の Body 要素を持つ XML 要素は、 と GetUserNameResponseにそれぞれ設定GetUserNameRequestされます。

<%@ WebService Language="C#" class="MyUser" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 public class MyUser : WebService {
 
       [ SoapDocumentMethod(Action="http://www.contoso.com/Sample", 
           RequestNamespace="http://www.contoso.com/Request",
           RequestElementName="GetUserNameRequest",
           ResponseNamespace="http://www.contoso.com/Response",
           ResponseElementName="GetUserNameResponse")]
      [ WebMethod(Description="Obtains the User Name") ]
      public UserName GetUserName() {
           string temp;
           int pos;
           UserName NewUser = new UserName();
           
           // Get the full user name, including the domain name if applicable.
           temp = User.Identity.Name;
 
           // Determine whether the user is part of a domain by searching for a backslash.
           pos = temp.IndexOf("\\");
           
           // Parse the domain name out of the string, if one exists.
           if (pos <= 0)
                 NewUser.Name = User.Identity.Name;
           else {
               NewUser.Name = temp.Remove(0,pos+1);
                 NewUser.Domain = temp.Remove(pos,temp.Length-pos);
           } 
       return NewUser;
      }
 
 }   
 
 public class UserName {
 
     public string Name;
     public string Domain;
 }
<%@ WebService Language="VB" class="MyUser" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class MyUser
    Inherits WebService    
    
    <SoapDocumentMethod(Action := "http://www.contoso.com/Sample", _
    RequestNamespace := "http://www.contoso.com/Request", _
    RequestElementName := "GetUserNameRequest", _
    ResponseNamespace := "http://www.contoso.com/Response", _
    ResponseElementName := "GetUserNameResponse"), _
    WebMethod(Description := "Obtains the User Name")> _
    Public Function GetUserName() As UserName
        
        Dim temp As String
        Dim pos As Integer
        Dim NewUser As New UserName()
        
        ' Get the full user name, including the domain name if applicable.
        temp = User.Identity.Name
        
        ' Determine whether the user is part of a Domain by searching for a backslash.
        pos = temp.IndexOf("\")
        
        ' Parse the domain name out of the string, if one exists.
        If pos <= 0 Then
            NewUser.Name = User.Identity.Name
        Else
            NewUser.Name = temp.Remove(0, pos + 1)
            NewUser.Domain = temp.Remove(pos, temp.Length - pos)
        End If
        Return NewUser
    End Function
End Class 

Public Class UserName
    
    Public Name As String
    Public Domain As String
End Class

注釈

Web サービス記述言語 (WSDL) では、操作を呼び出す XML Web サービス メソッドを SOAP メッセージ RPCDocumentで書式設定する方法について、2 つのスタイルを定義します。 Document は、XSD スキーマに従って XML Web サービス メソッドを書式設定することを指します。 スタイルは Document 、 要素の後に Body 続く 1 つ以上のメッセージ 部分の系列として要素を Body 書式設定することを指します。 個々のメッセージ 部分が プロパティと ParameterStyle プロパティによってUse決定される正確な方法。 プロパティは Use 、パラメーターの書式 Encoded を設定するか、 を指定するかを Literal決定します。 は ParameterStyle 、要素の後に続く 1 つのメッセージ パーツ内にパラメーターをカプセル化するか、各パラメーターが個々の Body メッセージ 部分であるかどうかを決定します。

詳細については、「 SOAP メッセージの書式設定のカスタマイズ」を参照してください。

この属性は、サーバー上の XML Web サービス メソッドと、クライアント上のプロキシ クラスのメソッドの両方に適用できます。

コンストラクター

SoapDocumentMethodAttribute()

SoapDocumentMethodAttribute クラスの新しいインスタンスを初期化します。

SoapDocumentMethodAttribute(String)

SoapDocumentMethodAttribute プロパティを action パラメーターの値に設定して、Action クラスの新しいインスタンスを初期化します。

プロパティ

Action

SOAP 要求の SOAPAction HTTP ヘッダー フィールドを取得または設定します。

Binding

XML Web サービス メソッドが実装している操作のバインディングを取得または設定します。

OneWay

Web サーバーが XML Web サービス メソッドの処理を完了するまで XML Web サービス クライアントが待機するかどうかを示す値を取得または設定します。

ParameterStyle

SOAP メッセージの XML 部分の Body 要素の下にある単一の XML 要素内に、パラメーターをカプセル化するかどうかを示す値を取得または設定します。

RequestElementName

サービスの説明で操作として定義されている XML Web サービス メソッドに対する SOAP 要求に関連付けられている XML 要素を取得または設定します。

RequestNamespace

XML Web サービス メソッドに対する SOAP 要求に関連付けられている名前空間を取得または設定します。

ResponseElementName

XML Web サービス メソッドに対する SOAP 応答に関連付けられている XML 要素を取得または設定します。

ResponseNamespace

XML Web サービス メソッドに対する SOAP 応答に関連付けられている XML 名前空間を取得または設定します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)
Use

SOAP メッセージの XML 部分内にある XML Web サービス メソッドのパラメーターの書式を取得または設定します。

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください