OperationFault Class
.NET Framework 3.0
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)
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 ); } }
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
System.Object
System.Web.Services.Description.DocumentableItem
System.Web.Services.Description.NamedItem
System.Web.Services.Description.OperationMessage
System.Web.Services.Description.OperationFault
System.Web.Services.Description.DocumentableItem
System.Web.Services.Description.NamedItem
System.Web.Services.Description.OperationMessage
System.Web.Services.Description.OperationFault
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.Community Additions
ADD
Show: