SoapHeader.MustUnderstand Property
Gets or sets a value indicating whether the SoapHeader must be understood.
[Visual Basic] Public Property MustUnderstand As Boolean [C#] public bool MustUnderstand {get; set;} [C++] public: __property bool get_MustUnderstand(); public: __property void set_MustUnderstand(bool); [JScript] public function get MustUnderstand() : Boolean; public function set MustUnderstand(Boolean);
Property Value
true if the XML Web service must properly interpret and process the SoapHeader;otherwise, false. The default is false.
Remarks
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 Using SOAP Headers.
Example
[Visual Basic, C#, C++] 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.
[Visual Basic] Imports System Public Class Sample Public Shared Sub Main() Dim ws As New MyWebService() Try Dim customHeader As New MyHeader1() customHeader.MyValue = "Header Value for MyValue" customHeader.MustUnderstand = True ws.myHeader = customHeader Dim results As Integer results = ws.MyWebMethod(3,5) Catch e As Exception Console.WriteLine("Exception: {0}", e.ToString()) End Try End Sub End Class [C#] 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()); } } } [C++] int main() { MyWebService* ws = new MyWebService(); try { MyHeader* customHeader = new MyHeader(); customHeader->MyValue = S"Header Value for MyValue"; customHeader->MustUnderstand = true; ws->myHeader = customHeader; int results = ws->MyWebMethod(3,5); } catch (Exception* e) { Console::WriteLine (S"Exception: {0}", e); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
SoapHeader Class | SoapHeader Members | System.Web.Services.Protocols Namespace | DidUnderstand | SoapHeaderException