Operation Class

Provides an abstract definition of an action supported by the XML Web service. This class cannot be inherited.

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

Public NotInheritable Class Operation
	Inherits NamedItem
Dim instance As Operation

public final class Operation extends NamedItem
public final class Operation extends NamedItem
Not applicable.

The Operation class corresponds to the Web Services Description Language (WSDL) operation element enclosed by the portType element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.

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.

Imports System
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MyOperationClass
   Public Shared Sub Main()
      Dim myDescription As ServiceDescription = ServiceDescription.Read("Operation_5_Input_VB.wsdl")
      ' Create a 'PortType' object.
      Dim myPortType As New PortType()
      myPortType.Name = "OperationServiceHttpPost"
      Dim myOperation As Operation = CreateOperation("AddNumbers", "s0:AddNumbersHttpPostIn", _
      ' Get the PortType of the Operation. 
      Dim myPort As PortType = myOperation.PortType
        Console.WriteLine( _
           "The port type of the operation is: " & myPort.Name)
      ' Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
      ' Write the 'ServiceDescription' as a WSDL file.
      Console.WriteLine("WSDL file with name 'Operation_5_Output_VB.wsdl'" + _ 
                           "file created Successfully")
   End Sub 'Main
   Public Shared Function CreateOperation(myOperationName As String, myInputMesg As String, _
                                                         myOutputMesg As String) As Operation
      ' Create an Operation.
      Dim myOperation As New Operation()
      myOperation.Name = myOperationName
      Dim myInput As OperationMessage = _
         CType(New OperationInput(), OperationMessage)
      myInput.Message = New XmlQualifiedName(myInputMesg)
      Dim myOutput As OperationMessage = _
         CType(New OperationOutput(), OperationMessage)
      myOutput.Message = New XmlQualifiedName(myOutputMesg)

      ' Add messages to the OperationMessageCollection.
      Console.WriteLine("Operation name is: " & myOperation.Name)
      Return myOperation
   End Function 'CreateOperation 
End Class 'MyOperationClass 

import System.*;  
import System.Web.Services.Description.*;  
import System.Collections.*;  
import System.Xml.*;  

class MyOperationClass
    public static void main(String[] args)
        ServiceDescription myDescription = ServiceDescription.
        // Create a 'PortType' object.
        PortType myPortType = new PortType();
        Operation myOperation = CreateOperation("AddNumbers", 
            "s0:AddNumbersHttpPostIn", "s0:AddNumbersHttpPostOut");
        // Get the PortType of the Operation. 
        PortType myPort = myOperation.get_PortType();
        Console.WriteLine("The port type of the operation is: " 
            + myPort.get_Name());
        // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
        // Write the 'ServiceDescription' as a WSDL file.
        Console.WriteLine("WSDL file with name 'Operation_5_Output_JSL.wsdl' "
            + "file created Successfully");
    } //main

    public static Operation CreateOperation(String myOperationName, 
        String myInputMesg, String myOutputMesg)
        // Create an Operation.
        Operation myOperation = new Operation();
        OperationMessage myInput = (OperationMessage)new OperationInput();
        myInput.set_Message(new XmlQualifiedName(myInputMesg));
        OperationMessage myOutput = (OperationMessage)new OperationOutput();
        myOutput.set_Message(new XmlQualifiedName(myOutputMesg));
        // Add messages to the OperationMessageCollection.
        Console.WriteLine("Operation name is: " + myOperation.get_Name());
        return myOperation;
    } //CreateOperation
} //MyOperationClass

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions