次の方法で共有


SoapHeader.MustUnderstand プロパティ

SoapHeader を認識する必要があるかどうかを示す値を取得または設定します。

Public Property MustUnderstand As Boolean
[C#]
public bool MustUnderstand {get; set;}
[C++]
public: __property bool get_MustUnderstand();public: __property void set_MustUnderstand(bool);
[JScript]
public function get MustUnderstand() : Boolean;public function set MustUnderstand(Boolean);

プロパティ値

XML Web サービスが SoapHeader を適切に解釈して処理する必要がある場合は true 。それ以外の場合は false 。既定値は false です。

解説

XML Web サービス クライアントが MustUnderstand プロパティを true に設定して XML Web サービス メソッドの呼び出しに SOAP ヘッダーを追加すると、XML Web サービス メソッドは DidUnderstand プロパティを true に設定する必要があります。それ以外の場合は、ASP.NET が SoapHeaderException を XML Web サービス クライアントにスローします。

EncodedMustUnderstand プロパティと MustUnderstand プロパティの両方を使用して、SOAP ヘッダー内の mustUnderstand 属性の値を設定できますが、 MustUnderstand プロパティでは、Boolean 値を使用して属性を設定できます。

クライアントへ SOAP ヘッダーを追加する場合の詳細については、「 SOAP ヘッダーの使用 」を参照してください。

使用例

[Visual Basic, C#, C++] XML Web サービス クライアントが、 MyHeader 型のカスタム SOAP ヘッダーを定義し、 MustUnderstand プロパティを true に設定して、 MyWebMethod XML Web サービス メソッドを呼び出す例を次に示します。XML Web サービス メソッドが MyHeader SOAP ヘッダーの DidUnderstand プロパティを true に設定しない場合は、 SoapHeaderException がスローされます。

 
Imports System

Public Class Sample
    
    Public Shared Sub Main()
        Dim ws As New MyWebService()

        Try
            Dim customHeader As New MyHeader1()

            customHeader.MyValue = "Header Value for MyValue"
            customHeader.MustUnderstand = True

            ws.myHeader = customHeader

        Dim results As Integer

            results = ws.MyWebMethod(3,5)
        Catch e As Exception
            Console.WriteLine("Exception: {0}", e.ToString())
        End Try
    End Sub
End Class


[C#] 
using System;

public class Sample {
    
    public static void Main() {
        MyWebService ws = new MyWebService();

        try {
            MyHeader customHeader = new MyHeader();
            customHeader.MyValue = "Header Value for MyValue";
            customHeader.MustUnderstand = true;
            ws.myHeader = customHeader;
            
        int results = ws.MyWebMethod(3,5);
        }
        catch (Exception e) {
            Console.WriteLine ("Exception: {0}", e.ToString());
        }
    }
}


[C++] 

int main() {
   MyWebService* ws = new MyWebService();

   try {
      MyHeader* customHeader = new MyHeader();
      customHeader->MyValue = S"Header Value for MyValue";
      customHeader->MustUnderstand = true;
      ws->myHeader = customHeader;

      int results = ws->MyWebMethod(3,5);
   }
   catch (Exception* e) {
      Console::WriteLine (S"Exception: {0}", e);
   }
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

SoapHeader クラス | SoapHeader メンバ | System.Web.Services.Protocols 名前空間 | DidUnderstand | SoapHeaderException