Share via


OperationMessageCollection Classe

Definição

Representa uma coleção de mensagens OperationInput e OperationOutput relacionadas a um serviço Web XML. Essa classe não pode ser herdada.

public ref class OperationMessageCollection sealed : System::Web::Services::Description::ServiceDescriptionBaseCollection
public sealed class OperationMessageCollection : System.Web.Services.Description.ServiceDescriptionBaseCollection
type OperationMessageCollection = class
    inherit ServiceDescriptionBaseCollection
Public NotInheritable Class OperationMessageCollection
Inherits ServiceDescriptionBaseCollection
Herança

Exemplos

#using <System.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Xml;
using namespace System::Web::Services;
using namespace System::Web::Services::Description;

// Displays the properties of the OperationMessageCollection.
void DisplayFlowInputOutput( OperationMessageCollection^ myOperationMessageCollection, String^ myOperation )
{
   Console::WriteLine( "After {0}:", myOperation );
   Console::WriteLine( "Flow : {0}", myOperationMessageCollection->Flow );
   Console::WriteLine( "The first occurrence of operation Input in the collection {0}", myOperationMessageCollection->Input );
   Console::WriteLine( "The first occurrence of operation Output in the collection {0}", myOperationMessageCollection->Output );
   Console::WriteLine();
}

int main()
{
   try
   {
      ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" );
      PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes;

      // Get the OperationCollection for the SOAP protocol.
      OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations;

      // Get the OperationMessageCollection for the Add operation.
      OperationMessageCollection^ myOperationMessageCollection = myOperationCollection[ 0 ]->Messages;

      // Display the Flow, Input, and Output properties.
      DisplayFlowInputOutput( myOperationMessageCollection, "Start" );

      // Get the operation message for the Add operation.
      OperationMessage^ myOperationMessage = myOperationMessageCollection[ 0 ];
      OperationMessage^ myInputOperationMessage = dynamic_cast<OperationMessage^>(gcnew OperationInput);
      XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace );
      myInputOperationMessage->Message = myXmlQualifiedName;

      array<OperationMessage^>^myCollection = gcnew array<OperationMessage^>(myOperationMessageCollection->Count);
      myOperationMessageCollection->CopyTo( myCollection, 0 );
      Console::WriteLine( "Operation name(s) :" );
      for ( int i = 0; i < myCollection->Length; i++ )
      {
         Console::WriteLine( " {0}", myCollection[ i ]->Operation->Name );
      }

      // Add the OperationMessage to the collection.
      myOperationMessageCollection->Add( myInputOperationMessage );
      
      DisplayFlowInputOutput( myOperationMessageCollection, "Add" );
      
      if ( myOperationMessageCollection->Contains( myOperationMessage ) == true )
      {
         int myIndex = myOperationMessageCollection->IndexOf( myOperationMessage );
         Console::WriteLine( " The index of the Add operation message in the collection is : {0}", myIndex );
      }

      myOperationMessageCollection->Remove( myInputOperationMessage );

      // Display Flow, Input, and Output after removing.
      DisplayFlowInputOutput( myOperationMessageCollection, "Remove" );

      // Insert the message at index 0 in the collection.
      myOperationMessageCollection->Insert( 0, myInputOperationMessage );

      // Display Flow, Input, and Output after inserting.
      DisplayFlowInputOutput( myOperationMessageCollection, "Insert" );

      myDescription->Write( "MathService_new_cs.wsdl" );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception caught!!!" );
      Console::WriteLine( "Source : {0}", e->Source );
      Console::WriteLine( "Message : {0}", e->Message );
   }
}
using System;
using System.Xml;
using System.Web.Services;
using System.Web.Services.Description;

class MyOperationMessageCollectionSample
{
   static void Main()
   {
      try
      {
         ServiceDescription myDescription =
            ServiceDescription.Read("MathService_input_cs.wsdl");
         PortTypeCollection myPortTypeCollection  =
            myDescription.PortTypes;

         // Get the OperationCollection for the SOAP protocol.
         OperationCollection myOperationCollection =
            myPortTypeCollection[0].Operations;

         // Get the OperationMessageCollection for the Add operation.
         OperationMessageCollection myOperationMessageCollection =
            myOperationCollection[0].Messages;

         // Display the Flow, Input, and Output properties.
         DisplayFlowInputOutput(myOperationMessageCollection, "Start");

         // Get the operation message for the Add operation.
         OperationMessage myOperationMessage =
            myOperationMessageCollection[0];
         OperationMessage myInputOperationMessage =
            (OperationMessage) new OperationInput();
         XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName(
            "AddSoapIn", myDescription.TargetNamespace);
         myInputOperationMessage.Message = myXmlQualifiedName;

         OperationMessage[] myCollection =
            new OperationMessage[myOperationMessageCollection.Count];
         myOperationMessageCollection.CopyTo(myCollection, 0);
         Console.WriteLine("Operation name(s) :");
         for (int i = 0; i < myCollection.Length ; i++)
         {
            Console.WriteLine(" " + myCollection[i].Operation.Name);
         }

         // Add the OperationMessage to the collection.
         myOperationMessageCollection.Add(myInputOperationMessage);
         DisplayFlowInputOutput(myOperationMessageCollection, "Add");

         if(myOperationMessageCollection.Contains(myOperationMessage)
            == true )
         {
            int myIndex =
               myOperationMessageCollection.IndexOf(myOperationMessage);
            Console.WriteLine(" The index of the Add operation " +
               "message in the collection is : " + myIndex);
         }

         myOperationMessageCollection.Remove(myInputOperationMessage);

         // Display Flow, Input, and Output after removing.
         DisplayFlowInputOutput(myOperationMessageCollection, "Remove");

         // Insert the message at index 0 in the collection.
         myOperationMessageCollection.Insert(0, myInputOperationMessage);

         // Display Flow, Input, and Output after inserting.
         DisplayFlowInputOutput(myOperationMessageCollection, "Insert");

         myDescription.Write("MathService_new_cs.wsdl");
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception caught!!!");
         Console.WriteLine("Source : " + e.Source);
         Console.WriteLine("Message : " + e.Message);
      }
   }

   // Displays the properties of the OperationMessageCollection.
   public static void DisplayFlowInputOutput( OperationMessageCollection
      myOperationMessageCollection, string myOperation)
   {
      Console.WriteLine("After " + myOperation + ":");
      Console.WriteLine("Flow : " + myOperationMessageCollection.Flow);
      Console.WriteLine("The first occurrence of operation Input " +
         "in the collection " + myOperationMessageCollection.Input);
      Console.WriteLine("The first occurrence of operation Output " +
         "in the collection " + myOperationMessageCollection.Output);
      Console.WriteLine();
   }
}
Imports System.Xml
Imports System.Web.Services
Imports System.Web.Services.Description

Class MyOperationMessageCollectionSample
   
   Shared Sub Main()
      Try
         Dim myDescription As ServiceDescription = _
            ServiceDescription.Read("MathService_input_vb.wsdl")
         Dim myPortTypeCollection As PortTypeCollection = _
            myDescription.PortTypes

         ' Get the OperationCollection for the SOAP protocol.
         Dim myOperationCollection As OperationCollection = _
            myPortTypeCollection(0).Operations

         ' Get the OperationMessageCollection for the Add operation.
         Dim myOperationMessageCollection As OperationMessageCollection = _
            myOperationCollection(0).Messages
         ' Display the Flow, Input, and Output properties.
         DisplayFlowInputOutput(myOperationMessageCollection, "Start")

         ' Get the operation message for the Add operation.
         Dim myOperationMessage As OperationMessage = _
            myOperationMessageCollection.Item(0)
         Dim myInputOperationMessage As OperationMessage = _
            CType(New OperationInput(), OperationMessage)
         Dim myXmlQualifiedName As _
            New XmlQualifiedName("AddSoapIn", myDescription.TargetNamespace)
         myInputOperationMessage.Message = myXmlQualifiedName
         
         Dim myCollection(myOperationMessageCollection.Count -1 ) _
            As OperationMessage
         myOperationMessageCollection.CopyTo(myCollection, 0)
         Console.WriteLine("Operation name(s) :")
         Dim i As Integer
         For i = 0 To myCollection.Length - 1
            Console.WriteLine(" " & myCollection(i).Operation.Name)
         Next i

         ' Add the OperationMessage to the collection.
         myOperationMessageCollection.Add(myInputOperationMessage)
         DisplayFlowInputOutput(myOperationMessageCollection, "Add")
         
         If myOperationMessageCollection.Contains(myOperationMessage) _
            = True Then
            Dim myIndex As Integer = _
               myOperationMessageCollection.IndexOf(myOperationMessage)
            Console.WriteLine(" The index of the Add operation " & _
                "message in the collection is : " & myIndex.ToString())
         End If

         myOperationMessageCollection.Remove(myInputOperationMessage)

         ' Display Flow, Input, and Output after removing.
         DisplayFlowInputOutput(myOperationMessageCollection, "Remove")

         ' Insert the message at index 0 in the collection.
         myOperationMessageCollection.Insert(0, myInputOperationMessage)

         ' Display Flow, Input, and Output after inserting.
         DisplayFlowInputOutput(myOperationMessageCollection, "Insert")

         myDescription.Write("MathService_new_vb.wsdl")
      Catch e As Exception
         Console.WriteLine("Exception caught!!!")
         Console.WriteLine("Source : " & e.Source.ToString())
         Console.WriteLine("Message : " & e.Message.ToString())
      End Try
   End Sub
   
   ' Displays the properties of the OperationMessageCollection.
   Public Shared Sub DisplayFlowInputOutput(myOperationMessageCollection As  _
      OperationMessageCollection, myOperation As String)

      Console.WriteLine("After " & myOperation.ToString() & ":")
      Console.WriteLine("Flow : " & _
         myOperationMessageCollection.Flow.ToString())
      Console.WriteLine("The first occurrence of operation Input " & _
         "in the collection {0}" , myOperationMessageCollection.Input)
      Console.WriteLine("The first occurrence of operation Output " & _
         "in the collection " &  myOperationMessageCollection.Output.ToString())
      Console.WriteLine()
   End Sub
End Class

Comentários

Uma instância dessa classe será retornada pela Messages propriedade do pai Operation. Como tal, ele pode ter exatamente dois membros, um OperationInput e outro um OperationOutput.

Propriedades

Capacity

Obtém ou define o número de elementos que o CollectionBase pode conter.

(Herdado de CollectionBase)
Count

Obtém o número de elementos contidos na instância de CollectionBase. Essa propriedade não pode ser substituída.

(Herdado de CollectionBase)
Flow

Obtém o tipo de transmissão compatível com OperationMessageCollection.

InnerList

Obtém uma ArrayList que contém a lista de elementos na instância de CollectionBase.

(Herdado de CollectionBase)
Input

Obtém a primeira ocorrência de um OperationInput dentro da coleção.

Item[Int32]

Obtém ou define o valor de um OperationMessage no índice de base zero especificado.

List

Obtém uma IList que contém a lista de elementos na instância de CollectionBase.

(Herdado de CollectionBase)
Output

Obtém a primeira ocorrência de um OperationOutput dentro da coleção.

Table

Obtém uma interface que implementa a associação das chaves e valores no ServiceDescriptionBaseCollection.

(Herdado de ServiceDescriptionBaseCollection)

Métodos

Add(OperationMessage)

Adiciona o OperationMessage especificado ao final do OperationMessageCollection.

Clear()

Remove todos os objetos da instância CollectionBase. Esse método não pode ser substituído.

(Herdado de CollectionBase)
Contains(OperationMessage)

Determina se o OperationMessage especificado é um membro da OperationMessageCollection.

CopyTo(OperationMessage[], Int32)

Copia todo o OperationMessageCollection para uma matriz unidimensional compatível do tipo OperationMessage, começando no índice de base zero especificado da matriz de destino.

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetEnumerator()

Retorna um enumerador que itera pela instância CollectionBase.

(Herdado de CollectionBase)
GetHashCode()

Serve como a função de hash padrão.

(Herdado de Object)
GetKey(Object)

Retorna o nome da chave associada com o valor passado por referência.

(Herdado de ServiceDescriptionBaseCollection)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IndexOf(OperationMessage)

Pesquisa o OperationMessage especificado e retorna o índice de base zero da primeira ocorrência dentro de toda a coleção.

Insert(Int32, OperationMessage)

Adiciona o OperationMessage especificado ao OperationMessageCollection no índice de base zero especificado.

MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
OnClear()

Limpa o conteúdo da instância ServiceDescriptionBaseCollection.

(Herdado de ServiceDescriptionBaseCollection)
OnClearComplete()

Executa processos adicionais personalizados após limpar o conteúdo da instância CollectionBase.

(Herdado de CollectionBase)
OnInsert(Int32, Object)

Executa os processos personalizados adicionais antes de inserir um novo elemento na instância CollectionBase.

(Herdado de CollectionBase)
OnInsertComplete(Int32, Object)

Realiza processos personalizados adicionais após inserir um novo elemento no ServiceDescriptionBaseCollection.

(Herdado de ServiceDescriptionBaseCollection)
OnRemove(Int32, Object)

Remove um elemento do ServiceDescriptionBaseCollection.

(Herdado de ServiceDescriptionBaseCollection)
OnRemoveComplete(Int32, Object)

Executa processos personalizados adicionais após remover um elemento da instância de CollectionBase.

(Herdado de CollectionBase)
OnSet(Int32, Object, Object)

Substitui um valor por outro dentro do ServiceDescriptionBaseCollection.

(Herdado de ServiceDescriptionBaseCollection)
OnSetComplete(Int32, Object, Object)

Executa processos personalizados adicionais após configurar um valor na instância de CollectionBase.

(Herdado de CollectionBase)
OnValidate(Object)

Executa processos personalizados adicionais ao validar um valor.

(Herdado de CollectionBase)
Remove(OperationMessage)

Remove a primeira ocorrência do OperationMessage especificado do OperationMessageCollection.

RemoveAt(Int32)

Remove o elemento no índice especificado da instância CollectionBase. Este método não é substituível.

(Herdado de CollectionBase)
SetParent(Object, Object)

Define o objeto pai da instância de ServiceDescriptionBaseCollection.

(Herdado de ServiceDescriptionBaseCollection)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

ICollection.CopyTo(Array, Int32)

Copia todo o CollectionBase em um Array unidimensional compatível, começando no índice especificado da matriz de destino.

(Herdado de CollectionBase)
ICollection.IsSynchronized

Obtém um valor que indica se o acesso à CollectionBase é sincronizado (thread-safe).

(Herdado de CollectionBase)
ICollection.SyncRoot

Obtém um objeto que pode ser usado para sincronizar o acesso ao CollectionBase.

(Herdado de CollectionBase)
IList.Add(Object)

Adiciona um objeto ao final do CollectionBase.

(Herdado de CollectionBase)
IList.Contains(Object)

Determina se o CollectionBase contém um elemento específico.

(Herdado de CollectionBase)
IList.IndexOf(Object)

Pesquisa o Object especificado e retorna o índice de base zero da primeira ocorrência dentro de todo o CollectionBase.

(Herdado de CollectionBase)
IList.Insert(Int32, Object)

Insere um elemento no CollectionBase, no índice especificado.

(Herdado de CollectionBase)
IList.IsFixedSize

Obtém um valor que indica se o CollectionBase tem um tamanho fixo.

(Herdado de CollectionBase)
IList.IsReadOnly

Obtém um valor que indica se o CollectionBase é somente leitura.

(Herdado de CollectionBase)
IList.Item[Int32]

Obtém ou define o elemento no índice especificado.

(Herdado de CollectionBase)
IList.Remove(Object)

Remove a primeira ocorrência de um objeto específico do CollectionBase.

(Herdado de CollectionBase)

Métodos de Extensão

Cast<TResult>(IEnumerable)

Converte os elementos de um IEnumerable para o tipo especificado.

OfType<TResult>(IEnumerable)

Filtra os elementos de um IEnumerable com base em um tipo especificado.

AsParallel(IEnumerable)

Habilita a paralelização de uma consulta.

AsQueryable(IEnumerable)

Converte um IEnumerable em um IQueryable.

Aplica-se a