Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

OperationFault Class

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

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
public sealed class OperationFault : OperationMessage
public final class OperationFault extends OperationMessage
public final class OperationFault extends OperationMessage
Not applicable.

Instances of this class are 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/.

The following example demonstrates the use of the properties and methods exposed by the OperationFault class.

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

import System.*;  
import System.Web.Services.Description.*;  
import System.Xml.*;  
import System.Xml.Schema.*;  
import System.Xml.Serialization.*;  

public class MyOperationFaultSample
{
    public static void main(String[] args)
    {
        try {
            // Read the 'StockQuote_jsl.wsdl' file as input.
            ServiceDescription myServiceDescription = ServiceDescription.
                Read("StockQuote_jsl.wsdl");
            PortTypeCollection myPortTypeCollection = myServiceDescription.
                get_PortTypes();
            PortType myPortType = myPortTypeCollection.get_Item(0);
            OperationCollection myOperationCollection = myPortType.
                get_Operations();
            Operation myOperation = myOperationCollection.get_Item(0);
            OperationFault myOperationFault = new OperationFault();
            myOperationFault.set_Name("ErrorString");
            myOperationFault.set_Message(new XmlQualifiedName(
                "s0:GetTradePriceStringFault"));
            myOperation.get_Faults().Add(myOperationFault);
            Console.WriteLine("Added OperationFault with Name: " 
                + myOperationFault.get_Name());
            myOperationFault = new OperationFault();
            myOperationFault.set_Name("ErrorInt");
            myOperationFault.set_Message(new XmlQualifiedName(
                "s0:GetTradePriceIntFault"));
            myOperation.get_Faults().Add(myOperationFault);
            myOperationCollection.Add(myOperation);
            Console.WriteLine("Added Second OperationFault with Name: " 
                + myOperationFault.get_Name());
            myServiceDescription.Write("StockQuoteNew_jsl.wsdl");
            Console.WriteLine("\nThe file 'StockQuoteNew_jsl.wsdl' is "
                + "created successfully.");
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception caught!!!");
            Console.WriteLine("Source : " + e.get_Source());
            Console.WriteLine("Message : " + e.get_Message());
        }
    } //main
} //MyOperationFaultSample

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 Millennium Edition, 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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.