Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ClientFaultCode Field

SoapException.ClientFaultCode Field

Specifies a SOAP fault code that represents a client call that is not formatted correctly or does not contain the appropriate information.

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

public static readonly XmlQualifiedName ClientFaultCode

An example of when a ClientFaultCode can be generated, is when a client call does not have proper authentication or payment information. It is generally an indication that the client call must be changed before it is resent.

<%@ WebService Language="C#" class="ThrowSoapException"%>

using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
using System.Xml;

public class ThrowSoapException : WebService 
    // This XML Web service method generates a SOAP client fault code. 
    public void myThrow(){

        // Build the detail element of the SOAP fault.
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        System.Xml.XmlNode node = doc.CreateNode(XmlNodeType.Element, 

        // Build specific details for the SoapException.
        // Add first child of detail XML element.
        System.Xml.XmlNode details = doc.CreateNode(XmlNodeType.Element, 
            "mySpecialInfo1", "http://tempuri.org/");
        System.Xml.XmlNode detailsChild = doc.CreateNode(XmlNodeType.Element, 
            "childOfSpecialInfo", "http://tempuri.org/");

        // Add second child of detail XML element with an attribute.
        System.Xml.XmlNode details2 = doc.CreateNode(XmlNodeType.Element, 
            "mySpecialInfo2", "http://tempuri.org/");
        XmlAttribute attr = doc.CreateAttribute("t", "attrName", 
        attr.Value = "attrValue";

        // Append the two child elements to the detail node.

        //Throw the exception.    
        SoapException se = new SoapException("Fault occurred", 

        throw se;
        return;    }

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft