Export (0) Print
Expand All

SoapHeader.DidUnderstand Property

Gets or sets a value indicating whether an XML Web service method properly processed a SOAP header.

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

public bool DidUnderstand { get; set; }

Property Value

Type: System.Boolean
true if the SOAP header was properly processed; otherwise false.

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.

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.

<%@ 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";
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft