OperationFault 类

定义

定义由 XML Web services 返回的错误信息的规范。 此类不能被继承。

public ref class OperationFault sealed : System::Web::Services::Description::OperationMessage
public sealed class OperationFault : System.Web.Services.Description.OperationMessage
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class OperationFault : System.Web.Services.Description.OperationMessage
type OperationFault = class
    inherit OperationMessage
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type OperationFault = class
    inherit OperationMessage
Public NotInheritable Class OperationFault
Inherits OperationMessage
继承
继承
属性

示例

以下示例演示如何使用 类 OperationFault 公开的属性和方法。

#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 );
   }
}
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);
      }
   }
}
Imports System.Web.Services.Description
Imports System.Xml
Imports System.Xml.Schema
Imports System.Xml.Serialization

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

注解

此类的实例是父Operation实例的 属性的成员Faults

OperationFault 对应于 Web 服务说明语言 (WSDL) fault 元素, operation 元素又被 元素括起来 portType 。 有关 WSDL 的更多信息,请参阅 WSDL 规范。

构造函数

OperationFault()

初始化 OperationFault 类的新实例。

属性

Documentation

获取或设置 DocumentableItem 的实例的文本文档。

(继承自 DocumentableItem)
DocumentationElement

获取或设置 DocumentableItem 的文档元素。

(继承自 DocumentableItem)
ExtensibleAttributes

获取或设置类型为 XmlAttribute 的数组,该数组表示为符合 Web 服务互操作性 (WS-I) 基本概要 1.1 而进行的 WSDL 特性扩展。

(继承自 DocumentableItem)
Extensions

获取与此 ServiceDescriptionFormatExtensionCollection 关联的 OperationFault

Extensions

获取与此 ServiceDescriptionFormatExtensionCollection 关联的 DocumentableItem

(继承自 DocumentableItem)
Message

获取或设置正在传送的数据的抽象的类型化的定义。

(继承自 OperationMessage)
Name

获取或设置 OperationMessage 的名称。

(继承自 OperationMessage)
Namespaces

获取或设置命名空间前缀和命名空间的字典,该字典用于在构造 ServiceDescription 对象时,保留命名空间的前缀和命名空间。

(继承自 DocumentableItem)
Operation

获取 Operation 为其成员的 OperationMessage

(继承自 OperationMessage)

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅