Operation Class
Provides an abstract definition of an action supported by the XML Web service. This class cannot be inherited.
Assembly: System.Web.Services (in System.Web.Services.dll)
The following example demonstrates a typical use of the Operation class. The example takes a ServiceDescription that does not have a PortType that supports the HTTP POST protocol. It adds a PortType instance that supports POST, and writes out a new WSDL contract.
#using <System.Xml.dll> #using <System.Web.Services.dll> #using <System.dll> using namespace System; using namespace System::Web::Services::Description; using namespace System::Collections; using namespace System::Xml; Operation^ CreateOperation( String^ myOperationName, String^ myInputMesg, String^ myOutputMesg ) { // Create an Operation. Operation^ myOperation = gcnew Operation; myOperation->Name = myOperationName; OperationMessage^ myInput = dynamic_cast<OperationMessage^>(gcnew OperationInput); myInput->Message = gcnew XmlQualifiedName( myInputMesg ); OperationMessage^ myOutput = dynamic_cast<OperationMessage^>(gcnew OperationOutput); myOutput->Message = gcnew XmlQualifiedName( myOutputMesg ); // Add messages to the OperationMessageCollection. myOperation->Messages->Add( myInput ); myOperation->Messages->Add( myOutput ); Console::WriteLine( "Operation name is: {0}", myOperation->Name ); return myOperation; } int main() { ServiceDescription^ myDescription = ServiceDescription::Read( "Operation_5_Input_CS.wsdl" ); // Create a 'PortType' object. PortType^ myPortType = gcnew PortType; myPortType->Name = "OperationServiceHttpPost"; Operation^ myOperation = CreateOperation( "AddNumbers", "s0:AddNumbersHttpPostIn", "s0:AddNumbersHttpPostOut" ); myPortType->Operations->Add( myOperation ); // Get the PortType of the Operation. PortType^ myPort = myOperation->PortType; Console::WriteLine( "The port type of the operation is: {0}", myPort->Name ); // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'. myDescription->PortTypes->Add( myPortType ); // Write the 'ServiceDescription' as a WSDL file. myDescription->Write( "Operation_5_Output_CS.wsdl" ); Console::WriteLine( "WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully" ); }
#using <mscorlib.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;
Operation* CreateOperation(String* myOperationName,String* myInputMesg,String* myOutputMesg)
{
// Create an Operation.
Operation* myOperation = new Operation();
myOperation->Name = myOperationName;
OperationMessage* myInput = dynamic_cast<OperationMessage*>(new OperationInput());
myInput->Message = new XmlQualifiedName(myInputMesg);
OperationMessage* myOutput = dynamic_cast<OperationMessage*>(new OperationOutput());
myOutput->Message = new XmlQualifiedName(myOutputMesg);
// Add messages to the OperationMessageCollection.
myOperation->Messages->Add(myInput);
myOperation->Messages->Add(myOutput);
Console::WriteLine(S"Operation name is: {0}", myOperation->Name);
return myOperation;
}
int main()
{
ServiceDescription* myDescription = ServiceDescription::Read(S"Operation_5_Input_CS.wsdl");
// Create a 'PortType' object.
PortType* myPortType = new PortType();
myPortType->Name = S"OperationServiceHttpPost";
Operation* myOperation = CreateOperation
(S"AddNumbers",S"s0:AddNumbersHttpPostIn",S"s0:AddNumbersHttpPostOut");
myPortType->Operations->Add(myOperation);
// Get the PortType of the Operation.
PortType* myPort = myOperation->PortType;
Console::WriteLine(
S"The port type of the operation is: {0}", myPort->Name);
// Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
myDescription->PortTypes->Add(myPortType);
// Write the 'ServiceDescription' as a WSDL file.
myDescription->Write(S"Operation_5_Output_CS.wsdl");
Console::WriteLine(S"WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully");
}
System.Web.Services.Description::DocumentableItem
System.Web.Services.Description::NamedItem
System.Web.Services.Description::Operation
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.