SoapHeader.MustUnderstand Propiedad

Definición

Obtiene o establece un valor que indica si debe reconocerse 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

Valor de propiedad

Boolean

Es true si el servicio Web XML debe interpretar y procesar correctamente SoapHeader; en caso contrario, es false. De manera predeterminada, es false.

Ejemplos

El siguiente cliente de servicio web XML define un encabezado SOAP personalizado de tipo MyHeader, establece la MustUnderstand propiedad trueen e invoca el método de MyWebMethod servicio web XML. Si el método de servicio web XML no establece la DidUnderstand propiedad del MyHeader encabezado trueSOAP en , se produce una SoapHeaderException excepción .

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

Comentarios

Cuando un cliente de servicio web XML agrega un encabezado SOAP a una llamada de método de servicio web XML con la MustUnderstand propiedad establecida trueen , el método de servicio web XML debe establecer la DidUnderstand propiedad trueen ; de lo contrario, se devuelve al SoapHeaderException cliente del servicio web XML mediante ASP.NET.

Aunque tanto las EncodedMustUnderstand propiedades como MustUnderstand se pueden usar para establecer el valor del mustUnderstand atributo dentro del encabezado SOAP, la MustUnderstand propiedad permite establecer el atributo mediante un valor booleano.

Para obtener más información sobre cómo agregar encabezados SOAP a los clientes, consulte Uso de encabezados SOAP.

Se aplica a

Consulte también