OperationFault Class
Defines the specifications for error messages returned by the XML Web service. This class cannot be inherited.
Assembly: System.Web.Services (in System.Web.Services.dll)
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.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 <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);
}
}
System.Web.Services.Description::DocumentableItem
System.Web.Services.Description::NamedItem
System.Web.Services.Description::OperationMessage
System.Web.Services.Description::OperationFault
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.