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

public sealed class SoapUnknownHeader : SoapHeader
public final class SoapUnknownHeader extends SoapHeader
public final class SoapUnknownHeader extends SoapHeader
Not applicable.

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;


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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions