次の方法で共有


SoapHeader.MustUnderstand プロパティ

定義

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

public:
 property bool MustUnderstand { bool get(); void set(bool value); };
public bool MustUnderstand { get; set; }
member this.MustUnderstand : bool with get, set
Public Property MustUnderstand As Boolean

プロパティ値

Boolean

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

次の XML Web サービス クライアントは、型MyHeaderのカスタム SOAP ヘッダーを定義し、プロパティをtrueMustUnderstand設定して、XML Web サービス メソッドをMyWebMethod呼び出します。 XML Web サービス メソッドで SOAP ヘッダーtrueMyHeaderプロパティがDidUnderstand設定されていない場合は、a SoapHeaderException がスローされます。

int main()
{
   MyWebService^ ws = gcnew MyWebService;
   try
   {
      MyHeader^ customHeader = gcnew 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 );
   }

}
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());
        }
    }
}
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

注釈

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

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

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

適用対象

こちらもご覧ください