Share via


MessageHeaderAttribute.MustUnderstand 속성

정의

Actor 역할에서 동작하는 노드가 이 헤더를 인식해야 하는지 여부를 지정합니다. 이 설정은 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

속성 값

Boolean

Actor 역할에서 동작하는 노드이면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 응답 메시지에 NameNamespace MustUnderstand 대 한 SOAP 헤더를 만드는 데 사용 하 고 MessageHeaderAttribute 속성이이 헤더에 대 한 적절 한 값으로 설정 합니다. 코드 예제 뒤에 메시지의 예제가 전송됩니다.

 [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

설명

자세한 내용은 설명 섹션 MessageHeaderAttribute 을 참조하세요.

중요

보내는 중인 메시지에서 MustUnderstand 속성이 true이고 받는 쪽 애플리케이션에서 헤더를 인식하지 못하면 오류가 생성됩니다. 반대로 SOAP 헤더 특성이 mustUnderstand 설정된 true 헤더가 Windows Communication Foundation(WCF)에서 수신되는 경우 메시지 계약의 일부여야 합니다(또는 Windows Communication Foundation(WCF) 채널 중 하나에서 처리해야 합니다. 그렇지 않으면 헤더가 이해되지 않고 예외가 throw되는 것으로 간주됩니다.

적용 대상