SoapHeader.DidUnderstand Property
Gets or sets a value indicating whether an XML Web service method properly processed a SOAP header.
[Visual Basic] Public Property DidUnderstand As Boolean [C#] public bool DidUnderstand {get; set;} [C++] public: __property bool get_DidUnderstand(); public: __property void set_DidUnderstand(bool); [JScript] public function get DidUnderstand() : Boolean; public function set DidUnderstand(Boolean);
Property Value
true if the SOAP header was properly processed; otherwise false.
Remarks
For SOAP headers defined by an XML Web service, ASP.NET assumes the XML Web service method properly processed the SOAP header by setting the initial value of DidUnderstand to true. For SOAP headers not defined by the XML Web service, the initial value is false. If ASP.NET detects SOAP headers passed to an XML Web service method with DidUnderstand set to false after the method returns, a SoapHeaderException is thrown back to the XML Web service client instead of the results from the XML Web service method.
Example
[Visual Basic, C#] The following MyWebService XML Web service defines the MyHeader SOAP header and requires it to be sent with any calls to the MyWebMethod XML Web service method. Additionally, the MyWebMethod receives any SOAP headers other than the MyHeader SOAP header. For SOAP headers that MyWebMethod can process, DidUnderstand is set to true.
[Visual Basic] <%@ WebService Language="VB" Class="MyWebService"%> Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Xml Imports System ' Define a SOAP header by deriving from the SoapHeader base class. Public Class MyHeader Inherits SoapHeader Public MyValue As String End Class Public Class MyWebService Public theHeader As MyHeader ' Receive all SOAP headers besides the MyHeader SOAP header. Public unknownHeaders() As SoapUnknownHeader 'Receive any SOAP headers other than MyHeader. <WebMethod, _ SoapHeader("theHeader", Direction := SoapHeaderDirection.InOut), _ SoapHeader("unknownHeaders")> _ Public Function MyWebMethod() As String Dim header As SoapUnknownHeader For Each header In unknownHeaders ' Perform some processing on the header. If header.Element.Name = "MyKnownHeader" Then header.DidUnderstand = True Else ' For those headers that cannot be ' processed, set the DidUnderstand propert to false. header.DidUnderstand = False End If Next header Return "Hello" End Function End Class [C#] <%@ WebService Language="C#" Class="MyWebService"%> using System.Web.Services; using System.Web.Services.Protocols; using System.Xml; using System; // Define a SOAP header by deriving from the SoapHeader base class. public class MyHeader : SoapHeader { public string MyValue; } public class MyWebService { public MyHeader myHeader; // Receive all SOAP headers besides the MyHeader SOAP header. public SoapUnknownHeader[] unknownHeaders; [WebMethod] [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)] //Receive any SOAP headers other than MyHeader. [SoapHeader("unknownHeaders",Required=false)] public string MyWebMethod() { foreach (SoapUnknownHeader header in unknownHeaders) { // Perform some processing on the header. if (header.Element.Name == "MyKnownHeader") header.DidUnderstand = true; else // For those headers that cannot be // processed, set the DidUnderstand property to false. header.DidUnderstand = false; } return "Hello"; } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic 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 | MustUnderstand | SoapHeaderException