This documentation is archived and is not being maintained.

SoapUnknownHeader Class

Represents the data received from a SOAP header that was not understood by the recipient XML Web service or XML Web service client. This class cannot be inherited.


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

public sealed class SoapUnknownHeader : SoapHeader

The SoapUnknownHeader type exposes the following members.

Public methodSoapUnknownHeaderInitializes a new instance of the SoapUnknownHeader class.

Public propertyActorGets or sets the recipient of the SOAP header. (Inherited from SoapHeader.)
Public propertyDidUnderstandGets or sets a value indicating whether an XML Web service method properly processed a SOAP header. (Inherited from SoapHeader.)
Public propertyElementGets or sets the XML Header element for a SOAP request or response.
Public propertyEncodedMustUnderstandGets or sets the value of the mustUnderstand XML attribute for the SOAP header when communicating with SOAP protocol version 1.1. (Inherited from SoapHeader.)
Public propertyEncodedMustUnderstand12Gets or sets the value of the mustUnderstand XML attribute for the SOAP header when communicating with SOAP protocol version 1.2. (Inherited from SoapHeader.)
Public propertyEncodedRelayGets or sets the relay attribute of the SOAP 1.2 header. (Inherited from SoapHeader.)
Public propertyMustUnderstandGets or sets a value indicating whether the SoapHeader must be understood. (Inherited from SoapHeader.)
Public propertyRelayGets or sets a value that indicates whether the SOAP header is to be relayed to the next SOAP node if the current node does not understand the header. (Inherited from SoapHeader.)
Public propertyRoleGets or sets the recipient of the SOAP header. (Inherited from SoapHeader.)

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

A SOAP client might invoke an XML Web service with additional data beyond the required parameters in the form of a SOAP header. An XML Web service created using ASP.NET or an XML Web service client can view any SOAP headers it did not know about at the time the XML Web service was written by applying a SoapHeaderAttribute with a MemberName property of either an array of SoapHeader, SoapHeader, SoapUnknownHeader or an array of SoapUnknownHeader to the XML Web service method. Specifying a Type of SoapUnknownHeader, allows the XML Web service to view the contents of the SOAP header in the form of an XmlElement.

The MyWebService XML Web service accepts and processes the MyHeader SOAP header sent with any calls to the MyWebMethod XML Web service method. Additionally, MyWebMethod receives any SOAP headers other than the MyHeader SOAP header.

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

    [SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]

    //Receive any SOAP headers other than MyHeader.

    public string MyWebMethod() {

    string unknownHeaderAttributes = String.Empty;

        // Set myHeader.MyValue to some value.

       foreach (SoapUnknownHeader header in unknownHeaders) {
           // Perform some processing on the header.
           foreach (XmlAttribute attribute in header.Element.Attributes) {
              unknownHeaderAttributes = unknownHeaderAttributes + attribute.Name + ":" + attribute.Value + ";";            
           // For those headers that cannot be 
           // processed, set the DidUnderstand property to false.
           header.DidUnderstand = false;
       return unknownHeaderAttributes;

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.