This documentation is archived and is not being maintained.

SoapHeaderException Class

The SOAP representation of a server error.

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

[SerializableAttribute]
public class SoapHeaderException : SoapException

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.

The Detail property cannot be set according to the SOAP specification for a SoapHeaderException.

NoteNote:

Applications that use the SOAP 1.1 specification as the service protocol can use the SoapHeaderException to access SOAP faults. However, applications that use the SOAP 1.2 specification must use the SoapException to access SOAP faults.

In the following example, an XML Web service client calls the MyWebMethod XML Web service method, passing in a SOAP header of type MyHeader with the MustUnderstand property set to true. If the XML Web service method does not set the DidUnderstand property of the MyHeader SOAP header to true, a SoapHeaderException is thrown.

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());
        }
    }
}
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);
   }
}

System.Object
  System.Exception
    System.SystemException
      System.Web.Services.Protocols.SoapException
        System.Web.Services.Protocols.SoapHeaderException

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Framework

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

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Show: