MessageHeaderAttribute.MustUnderstand Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Specifies whether the node acting in the Actor role must understand this header. This is mapped to the mustUnderstand SOAP header attribute.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public bool MustUnderstand { get; set; }

Property Value

Type: System.Boolean

true if the node acting in the Actor role must understand this header; otherwise, false.

For more information, see the Remarks section of MessageHeaderAttribute for details.


It is important to remember that if the MustUnderstand property is true in a message being sent and the application on the receiving side does not understand the header a fault is generated. Conversely, if a header with the mustUnderstand SOAP header attribute set to true is received by Windows Communication Foundation (WCF), it must be a part of the message contract (or must be processed by one of the Windows Communication Foundation (WCF) channels); otherwise, it is assumed that the header is not understood and an exception is thrown.

The following code example shows the use of the MessageHeaderAttribute to create a SOAP header for the response message with the Name, Namespace and MustUnderstand properties set to values appropriate for this header. The code example is followed by an example of the message when sent.

 public class HelloResponseMessage
   private string localResponse = String.Empty;
   private string extra = String.Empty;

     Name = "ResponseToGreeting",
     Namespace = "")]
   public string Response
     get { return localResponse; }
     set { localResponse = value; }

     Name = "OutOfBandData",
     Namespace = "",
   public string ExtraValues
     get { return extra; }
     set { this.extra = value; }

   The following is the response message, edited for clarity.

       <a:Action s:mustUnderstand="1">http://HelloResponseMessage/Action</a:Action>
       <h:OutOfBandData s:mustUnderstand="1" xmlns:h="">Served by object 13804354.</h:OutOfBandData>
       <HelloResponseMessage xmlns="Microsoft.WCF.Documentation">
         <ResponseToGreeting xmlns="">Service received: Hello.</ResponseToGreeting>

.NET Framework
Available since 3.0
Return to top