This documentation is archived and is not being maintained.

OperationMessageCollection Class

Represents a collection of OperationInput and OperationOutput messages related to an XML Web service. This class cannot be inherited.

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

public ref class OperationMessageCollection sealed : public ServiceDescriptionBaseCollection

An instance of this class will be returned by the Messages property of the parent Operation. As such, it can have exactly two members, one an OperationInput and the other an OperationOutput.

#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 <mscorlib.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(S"After {0}:", myOperation);
   Console::WriteLine(S"Flow : {0}", __box(myOperationMessageCollection->Flow));
   Console::WriteLine(S"The first occurrence of operation Input in the collection {0}", myOperationMessageCollection->Input );
   Console::WriteLine(S"The first occurrence of operation Output in the collection {0}", myOperationMessageCollection->Output );
   Console::WriteLine();
}

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

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

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

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

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

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

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

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

      myOperationMessageCollection->Remove(myInputOperationMessage);

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

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

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

      myDescription->Write(S"MathService_new_cs.wsdl");
   }
   catch(Exception* e)
   {
      Console::WriteLine(S"Exception caught!!!");
      Console::WriteLine(S"Source : {0}", e->Source);
      Console::WriteLine(S"Message : {0}", e->Message);
   }
}

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 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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: