Export (0) Print
Expand All

SoapHeader.MustUnderstand Property

Gets or sets a value indicating whether the SoapHeader must be understood.

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

public bool MustUnderstand { get; set; }

Property Value

Type: System.Boolean
true if the XML Web service must properly interpret and process the SoapHeader; otherwise, false. The default is false.

When an XML Web service client adds a SOAP header to an XML Web service method call with the MustUnderstand property set to true, the XML Web service method must set the DidUnderstand property to true; otherwise, a SoapHeaderException is thrown back to the XML Web service client by ASP.NET.

Although both the EncodedMustUnderstand and MustUnderstand properties can be used to set the value of the mustUnderstand attribute within the SOAP header, the MustUnderstand property allows you to set the attribute using a Boolean value.

For details on adding SOAP headers to clients, see [<topic://cpconusingsoapheaders>].

The following XML Web service client defines a custom SOAP header of type MyHeader, sets the MustUnderstand property to true, and invokes the MyWebMethod XML Web service method. If the XML Web service method does not set the DidUnderstand property of the MyHeader SOAP header to true, a SoapHeaderException is thrown.

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft