Freigeben über


OperationFault-Klasse

Definiert die Spezifikationen für Fehlermeldungen, die durch den XML-Webdienst zurückgegeben werden. Diese Klasse kann nicht geerbt werden.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Public NotInheritable Class OperationFault
    Inherits OperationMessage
'Usage
Dim instance As OperationFault
public sealed class OperationFault : OperationMessage
public ref class OperationFault sealed : public OperationMessage
public final class OperationFault extends OperationMessage
public final class OperationFault extends OperationMessage

Hinweise

Instanzen dieser Klasse sind Member der Faults-Eigenschaft der übergeordneten Operation-Instanz.

Die OperationFault-Klasse entspricht dem WSDL-fault-Element (Web Services Description Language), das vom operation-Element eingeschlossen wird, das wiederum vom portType-Element einschlossen wird. Weitere Informationen über WSDL finden Sie in der Spezifikation unter http://www.w3.org/TR/wsdl/.

Beispiel

Im folgenden Beispiel wird die Verwendung der Eigenschaften und Methoden veranschaulicht, die von der OperationFault-Klasse verfügbar gemacht werden.

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
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);
      }
   }
}
#using <System.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( "StockQuote_cpp.wsdl" );
      PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes;
      PortType^ myPortType = myPortTypeCollection[ 0 ];
      OperationCollection^ myOperationCollection = myPortType->Operations;
      Operation^ myOperation = myOperationCollection[ 0 ];
      
      OperationFault^ myOperationFault = gcnew OperationFault;
      myOperationFault->Name = "ErrorString";
      myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceStringFault" );
      myOperation->Faults->Add( myOperationFault );
      Console::WriteLine( "Added OperationFault with Name: {0}", myOperationFault->Name );
      myOperationFault = gcnew OperationFault;
      myOperationFault->Name = "ErrorInt";
      myOperationFault->Message = gcnew XmlQualifiedName( "s0:GetTradePriceIntFault" );
      myOperation->Faults->Add( myOperationFault );

      myOperationCollection->Add( myOperation );
      Console::WriteLine( "Added Second OperationFault with Name: {0}", myOperationFault->Name );
      myServiceDescription->Write( "StockQuoteNew_cpp.wsdl" );
      Console::WriteLine( "\nThe file 'StockQuoteNew_cpp.wsdl' is created successfully." );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception caught!!!" );
      Console::WriteLine( "Source : {0}", e->Source );
      Console::WriteLine( "Message : {0}", 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

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

OperationFault-Member
System.Web.Services.Description-Namespace
PortType
Operation-Klasse