Sdílet prostřednictvím


MessageHeaderAttribute.MustUnderstand Vlastnost

Definice

Určuje, jestli uzel fungující v Actor roli musí porozumět této hlavičce. To je namapováno na atribut hlavičky mustUnderstand SOAP.

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

Hodnota vlastnosti

truepokud uzel, který funguje v Actor roli, musí porozumět této hlavičce, jinak . false

Příklady

Následující příklad kódu ukazuje použití k vytvoření hlavičky MessageHeaderAttribute SOAP pro zprávu odpovědi se zprávou NameNamespace a MustUnderstand vlastnosti nastavené na hodnoty vhodné pro tuto hlavičku. Po příkladu kódu následuje příklad zprávy při odeslání.

 [MessageContract]
 public class HelloResponseMessage
 {
   private string localResponse = String.Empty;
   private string extra = String.Empty;

   [MessageBodyMember(
     Name = "ResponseToGreeting",
     Namespace = "http://www.examples.com")]
   public string Response
   {
     get { return localResponse; }
     set { localResponse = value; }
   }

   [MessageHeader(
     Name = "OutOfBandData",
     Namespace = "http://www.examples.com",
     MustUnderstand=true
   )]
   public string ExtraValues
   {
     get { return extra; }
     set { this.extra = value; }
  }

  /*
   The following is the response message, edited for clarity.

   <s:Envelope>
     <s:Header>
       <a:Action s:mustUnderstand="1">http://HelloResponseMessage/Action</a:Action>
       <h:OutOfBandData s:mustUnderstand="1" xmlns:h="http://www.examples.com">Served by object 13804354.</h:OutOfBandData>
     </s:Header>
     <s:Body>
       <HelloResponseMessage xmlns="Microsoft.WCF.Documentation">
         <ResponseToGreeting xmlns="http://www.examples.com">Service received: Hello.</ResponseToGreeting>
       </HelloResponseMessage>
     </s:Body>
   </s:Envelope>
   */
}
  <MessageContract> _
  Public Class HelloResponseMessage
    Private localResponse As String = String.Empty
    Private extra As String = String.Empty

    <MessageBodyMember(Name := "ResponseToGreeting", Namespace := "http://www.examples.com")> _
    Public Property Response() As String
      Get
          Return localResponse
      End Get
      Set(ByVal value As String)
          localResponse = value
      End Set
    End Property

    <MessageHeader(Name := "OutOfBandData", Namespace := "http://www.examples.com", MustUnderstand:=True)> _
    Public Property ExtraValues() As String
      Get
          Return extra
      End Get
      Set(ByVal value As String)
          Me.extra = value
      End Set
    End Property

'   
'    The following is the response message, edited for clarity.
'    
'    <s:Envelope>
'      <s:Header>
'        <a:Action s:mustUnderstand="1">http://HelloResponseMessage/Action</a:Action>
'        <h:OutOfBandData s:mustUnderstand="1" xmlns:h="http://www.examples.com">Served by object 13804354.</h:OutOfBandData>
'      </s:Header>
'      <s:Body>
'        <HelloResponseMessage xmlns="Microsoft.WCF.Documentation">
'          <ResponseToGreeting xmlns="http://www.examples.com">Service received: Hello.</ResponseToGreeting>
'      </s:Body>    
'    </s:Envelope>
'    
  End Class

Poznámky

Další informace najdete v části MessageHeaderAttribute Poznámky s podrobnostmi.

Důležité

Je důležité si uvědomit, že pokud MustUnderstand je vlastnost ve zprávě, která se true odesílá, a aplikace na přijímající straně nerozumí tomu, že se vygeneruje hlavička, která je chybou. Pokud je hlavička s atributem mustUnderstand hlavičky SOAP nastavená službou true Windows Communication Foundation (WCF), musí být součástí kontraktu zprávy (nebo musí být zpracována jedním z kanálů WCF (Windows Communication Foundation), jinak se předpokládá, že záhlaví není srozumitelné a vyvolá se výjimka.

Platí pro