This documentation is archived and is not being maintained.

OperationFault Class

Defines the specifications for error messages returned by the XML Web service. This class cannot be inherited.

For a list of all members of this type, see OperationFault Members.

System.Object
   System.Web.Services.Description.DocumentableItem
      System.Web.Services.Description.OperationMessage
         System.Web.Services.Description.OperationFault

[Visual Basic]
NotInheritable Public Class OperationFault
   Inherits OperationMessage
[C#]
public sealed class OperationFault : OperationMessage
[C++]
public __gc __sealed class OperationFault : public OperationMessage
[JScript]
public class OperationFault extends OperationMessage

Thread Safety

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

Remarks

Instances of this class will be members of the Faults property of the parent Operation instance.

The OperationFault class corresponds to the Web Services Description Language (WSDL) <fault> element enclosed by the <operation> element that is in turn enclosed by the <portType> element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.

Example

[Visual Basic, C#, C++] The following example demonstrates the use of the properties and methods exposed by the OperationFault class.

[Visual Basic] 
Imports System
Imports System.Web.Services.Description
Imports System.Xml
Imports System.Xml.Schema
Imports System.Xml.Serialization
Imports Microsoft.VisualBasic

Public Class MyOperationFaultSample
   Public Shared Sub Main()
      Try
         ' Read the 'StockQuote_vb.wsdl' file as input.
         Dim myServiceDescription As ServiceDescription = _
                              ServiceDescription.Read("StockQuote_vb.wsdl")
         Dim myPortTypeCollection As PortTypeCollection = _
                                           myServiceDescription.PortTypes
         Dim myPortType As PortType = myPortTypeCollection(0)
         Dim myOperationCollection As OperationCollection = myPortType.Operations
         Dim myOperation As Operation = myOperationCollection(0)
         Dim myOperationFault As New OperationFault()
         myOperationFault.Name = "ErrorString"
         myOperationFault.Message = _
                        New XmlQualifiedName("s0:GetTradePriceStringFault")
         myOperation.Faults.Add(myOperationFault)
         Console.WriteLine("Added OperationFault with Name: " + _
                                                     myOperationFault.Name)
         myOperationFault = New OperationFault()
         myOperationFault.Name = "ErrorInt"
         myOperationFault.Message = _
                           New XmlQualifiedName("s0:GetTradePriceIntFault")
         myOperation.Faults.Add(myOperationFault)
         myOperationCollection.Add(myOperation)
         Console.WriteLine("Added Second OperationFault with Name: " + _
                                                    myOperationFault.Name)
         myServiceDescription.Write("StockQuoteNew_vb.wsdl")
         Console.WriteLine(ControlChars.NewLine + _
                           "The file 'StockQuoteNew_vb.wsdl' is " + _
                           "created successfully.")
      Catch e As Exception
         Console.WriteLine("Exception caught!!!")
         Console.WriteLine("Source : " + e.Source)
         Console.WriteLine("Message : " + e.Message)
      End Try
   End Sub
End Class

[C#] 
using System;
using System.Web.Services.Description;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

public class MyOperationFaultSample
{
   public static void Main()
   {
      try 
      {
         // Read the 'StockQuote_cs.wsdl' file as input.
         ServiceDescription myServiceDescription = ServiceDescription.
                                               Read("StockQuote_cs.wsdl");
         PortTypeCollection myPortTypeCollection = myServiceDescription.
                                                                PortTypes;
         PortType myPortType = myPortTypeCollection[0];
         OperationCollection myOperationCollection = myPortType.Operations;
         Operation myOperation = myOperationCollection[0];
         OperationFault myOperationFault = new OperationFault();
         myOperationFault.Name = "ErrorString";
         myOperationFault.Message = new XmlQualifiedName
                                          ("s0:GetTradePriceStringFault");
         myOperation.Faults.Add(myOperationFault);
         Console.WriteLine("Added OperationFault with Name: "
                           + myOperationFault.Name);
         myOperationFault = new OperationFault();
         myOperationFault.Name = "ErrorInt";
         myOperationFault.Message = new XmlQualifiedName
                                             ("s0:GetTradePriceIntFault");
         myOperation.Faults.Add(myOperationFault);
         myOperationCollection.Add(myOperation);
         Console.WriteLine("Added Second OperationFault with Name: "
                  +myOperationFault.Name);
         myServiceDescription.Write("StockQuoteNew_cs.wsdl");
         Console.WriteLine("\nThe file 'StockQuoteNew_cs.wsdl' is " +
                           "created successfully.");
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception caught!!!");
         Console.WriteLine("Source : " + e.Source);
         Console.WriteLine("Message : " + e.Message);
      }
   }
}

[C++] 
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Xml;
using namespace System::Xml::Schema;
using namespace System::Xml::Serialization;

int main() 
{
   try 
   {
      // Read the 'StockQuote_cpp.wsdl' file as input.
      ServiceDescription* myServiceDescription = 
         ServiceDescription::Read(S"StockQuote_cpp.wsdl");
      PortTypeCollection* myPortTypeCollection = myServiceDescription->
         PortTypes;
      PortType* myPortType = myPortTypeCollection->Item[0];
      OperationCollection* myOperationCollection = myPortType->Operations;
      Operation* myOperation = myOperationCollection->Item[0];
      OperationFault* myOperationFault = new OperationFault();
      myOperationFault->Name = S"ErrorString";
      myOperationFault->Message = new XmlQualifiedName
         (S"s0:GetTradePriceStringFault");
      myOperation->Faults->Add(myOperationFault);
      Console::WriteLine(S"Added OperationFault with Name: {0}", myOperationFault->Name);
      myOperationFault = new OperationFault();
      myOperationFault->Name = S"ErrorInt";
      myOperationFault->Message = new XmlQualifiedName
         (S"s0:GetTradePriceIntFault");
      myOperation->Faults->Add(myOperationFault);
      myOperationCollection->Add(myOperation);
      Console::WriteLine(S"Added Second OperationFault with Name: {0}", 
         myOperationFault->Name);
      myServiceDescription->Write(S"StockQuoteNew_cpp.wsdl");
      Console::WriteLine(S"\nThe file 'StockQuoteNew_cpp.wsdl' is created successfully.");
   } 
   catch (Exception* e) 
   {
      Console::WriteLine(S"Exception caught!!!");
      Console::WriteLine(S"Source : {0}", e->Source);
      Console::WriteLine(S"Message : {0}", e->Message);
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.Services.Description

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

OperationFault Members | System.Web.Services.Description Namespace | PortType | Operation

Show: