Partilhar via


OperationMessageCollection Classe

Definição

Representa uma coleção de mensagens e OperationOutput mensagens OperationInput 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 ))
      {
         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))
         {
            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

Nome Description
Capacity

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

(Herdado de CollectionBase)
Count

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

(Herdado de CollectionBase)
Flow

Obtém o tipo de transmissão com suporte pelo OperationMessageCollection.

InnerList

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

(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 índice baseado em zero especificado.

List

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

(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

Nome Description
Add(OperationMessage)

Adiciona o especificado OperationMessage ao final do OperationMessageCollection.

Clear()

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

(Herdado de CollectionBase)
Contains(OperationMessage)

Determina se o especificado OperationMessage é um membro do OperationMessageCollection.

CopyTo(OperationMessage[], Int32)

Copia o todo 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 por meio da CollectionBase instância.

(Herdado de CollectionBase)
GetHashCode()

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

(Herdado de Object)
GetKey(Object)

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

(Herdado de ServiceDescriptionBaseCollection)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IndexOf(OperationMessage)

Pesquisa o índice especificado OperationMessage e retorna o índice baseado em zero da primeira ocorrência dentro da coleção.

Insert(Int32, OperationMessage)

Adiciona o especificado OperationMessage ao OperationMessageCollection índice baseado em zero especificado.

MemberwiseClone()

Cria uma cópia superficial do Objectatual.

(Herdado de Object)
OnClear()

Limpa o conteúdo da ServiceDescriptionBaseCollection instância.

(Herdado de ServiceDescriptionBaseCollection)
OnClearComplete()

Executa processos personalizados adicionais depois de limpar o conteúdo da CollectionBase instância.

(Herdado de CollectionBase)
OnInsert(Int32, Object)

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

(Herdado de CollectionBase)
OnInsertComplete(Int32, Object)

Executa processos personalizados adicionais depois de 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 depois de remover um elemento da CollectionBase instância.

(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 depois de definir um valor na CollectionBase instância.

(Herdado de CollectionBase)
OnValidate(Object)

Executa processos personalizados adicionais ao validar um valor.

(Herdado de CollectionBase)
Remove(OperationMessage)

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

RemoveAt(Int32)

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

(Herdado de CollectionBase)
SetParent(Object, Object)

Define o objeto pai da ServiceDescriptionBaseCollection instância.

(Herdado de ServiceDescriptionBaseCollection)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

Nome Description
ICollection.CopyTo(Array, Int32)

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

(Herdado de CollectionBase)
ICollection.IsSynchronized

Obtém um valor que indica se o CollectionBase acesso ao é 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 elemento contém um elemento específico.

(Herdado de CollectionBase)
IList.IndexOf(Object)

Pesquisa o índice especificado Object e retorna o índice baseado em zero da primeira ocorrência em todo CollectionBaseo .

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

Insere um elemento CollectionBase no índice especificado.

(Herdado de CollectionBase)
IList.IsFixedSize

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

(Herdado de CollectionBase)
IList.IsReadOnly

Obtém um valor que indica se o CollectionBase valor é 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

Nome Description
AsParallel(IEnumerable)

Habilita a paralelização de uma consulta.

AsQueryable(IEnumerable)

Converte um IEnumerable em um IQueryable.

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.

Aplica-se a