MessageHeaderAttribute.MustUnderstand Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Specifica se il nodo che agisce nel Actor ruolo deve comprendere questa intestazione. Viene eseguito il mapping all'attributo dell'intestazione 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
Valore della proprietà
true se il nodo che agisce nel Actor ruolo deve comprendere questa intestazione; in caso contrario, false.
Esempio
Nell'esempio di codice seguente viene illustrato l'uso di MessageHeaderAttribute per creare un'intestazione SOAP per il messaggio di risposta con le Nameproprietà e NamespaceMustUnderstand impostate sui valori appropriati per questa intestazione. L'esempio di codice è seguito da un esempio del messaggio quando viene inviato.
[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
Commenti
Per altre informazioni, vedere la sezione Osservazioni di MessageHeaderAttribute per informazioni dettagliate.
Importante
È importante ricordare che se la MustUnderstand proprietà si trova true in un messaggio inviato e l'applicazione sul lato ricevente non comprende l'intestazione generata da un errore. Viceversa, se un'intestazione con l'attributo dell'intestazione mustUnderstand SOAP impostata su true viene ricevuta da Windows Communication Foundation (WCF), deve far parte del contratto di messaggio (o deve essere elaborata da uno dei canali Windows Communication Foundation (WCF). In caso contrario, si presuppone che l'intestazione non venga riconosciuta e venga generata un'eccezione.