Exportar (0) Imprimir
Expandir todo

Operation (Clase)

Actualización: noviembre 2007

Proporciona una definición abstracta de una acción admitida por el servicio Web XML. No se puede heredar esta clase.

Espacio de nombres:  System.Web.Services.Description
Ensamblado:  System.Web.Services (en System.Web.Services.dll)

[XmlFormatExtensionPointAttribute("Extensions")]
public sealed class Operation : NamedItem
/** @attribute XmlFormatExtensionPointAttribute("Extensions") */
public final class Operation extends NamedItem
public final class Operation extends NamedItem

La clase Operation se corresponde con el elemento operation de Lenguaje de descripción de servicios Web (WSDL) incluido dentro del elemento portType. Para obtener más información acerca de WSDL, vea la especificación en http://www.w3.org/TR/wsdl/.

En el siguiente ejemplo se muestra un uso común de la clase Operation. El ejemplo toma un ServiceDescription que no tiene un PortType que admita el protocolo HTTP POST. Agrega una instancia de PortType que admite POST y escribe un nuevo contrato WSDL.

using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

class MyOperationClass
{
   public static void Main()
   {
      ServiceDescription myDescription = ServiceDescription.Read("Operation_5_Input_CS.wsdl");
      // Create a 'PortType' object.
      PortType myPortType = new 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: " + 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");
   }
   public static Operation CreateOperation(string myOperationName,string myInputMesg,string myOutputMesg)
   {
      // Create an Operation.
      Operation myOperation = new Operation();
      myOperation.Name = myOperationName;
      OperationMessage myInput = (OperationMessage)new OperationInput();
      myInput.Message =  new XmlQualifiedName(myInputMesg);
      OperationMessage myOutput = (OperationMessage)new OperationOutput();
      myOutput.Message = new XmlQualifiedName(myOutputMesg);

      // Add messages to the OperationMessageCollection.
      myOperation.Messages.Add(myInput);
      myOperation.Messages.Add(myOutput);
      Console.WriteLine("Operation name is: " + myOperation.Name);     
      return myOperation;
   }
}


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

class MyOperationClass
{
    public static void main(String[] args)
    {
        ServiceDescription myDescription = ServiceDescription.
            Read("Operation_5_Input_JSL.wsdl");
        // Create a 'PortType' object.
        PortType myPortType = new PortType();
        myPortType.set_Name("OperationServiceHttpPost");
        Operation myOperation = CreateOperation("AddNumbers", 
            "s0:AddNumbersHttpPostIn", "s0:AddNumbersHttpPostOut");
        myPortType.get_Operations().Add(myOperation);
        // 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'.
        myDescription.get_PortTypes().Add(myPortType);
        // Write the 'ServiceDescription' as a WSDL file.
        myDescription.Write("Operation_5_Output_JSL.wsdl");
        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();
        myOperation.set_Name(myOperationName);
        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.
        myOperation.get_Messages().Add(myInput);
        myOperation.get_Messages().Add(myOutput);
        Console.WriteLine("Operation name is: " + myOperation.get_Name());
        return myOperation;
    } //CreateOperation
} //MyOperationClass


Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft