Export (0) Print
Expand All

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 sealed class OperationMessageCollection : ServiceDescriptionBaseCollection
public final class OperationMessageCollection extends ServiceDescriptionBaseCollection
public final class OperationMessageCollection extends ServiceDescriptionBaseCollection
Not applicable.

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;
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();
   }
}

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

class MyOperationMessageCollectionSample
{
    public static void main(String[] args)
    {
        try {
            ServiceDescription myDescription = ServiceDescription.
                Read("MathService_input_jsl.wsdl");
            PortTypeCollection myPortTypeCollection = myDescription.
                get_PortTypes();
            // Get the OperationCollection for the SOAP protocol.
            OperationCollection myOperationCollection = myPortTypeCollection.
                get_Item(0).get_Operations();
            // Get the OperationMessageCollection for the Add operation.
            OperationMessageCollection myOperationMessageCollection = 
                myOperationCollection.get_Item(0).get_Messages();
            // Display the Flow, Input, and Output properties.
            DisplayFlowInputOutput(myOperationMessageCollection, "Start");
            // Get the operation message for the Add operation.
            OperationMessage myOperationMessage = myOperationMessageCollection.
                get_Item(0);
            OperationMessage myInputOperationMessage = (OperationMessage)
                new OperationInput();
            XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName(
                "AddSoapIn", myDescription.get_TargetNamespace());
            myInputOperationMessage.set_Message(myXmlQualifiedName);
            OperationMessage myCollection[] = 
                new OperationMessage[myOperationMessageCollection.get_Count()];
            myOperationMessageCollection.CopyTo(myCollection, 0);
            Console.WriteLine("Operation name(s) :");
            for (int i = 0; i < myCollection.get_Length(); i++) {
                Console.WriteLine(" " + myCollection[i].get_Operation().
                    get_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_jsl.wsdl");
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception caught!!!");
            Console.WriteLine("Source : " + e.get_Source());
            Console.WriteLine("Message : " + e.get_Message());
        }
    } //main

    // Displays the properties of the OperationMessageCollection.
    public static void DisplayFlowInputOutput(
        OperationMessageCollection myOperationMessageCollection,
        String myOperation)
    {
        Console.WriteLine("After " + myOperation + ":");
        Console.WriteLine("Flow : " + myOperationMessageCollection.get_Flow());
        Console.WriteLine("The first occurrence of operation Input " 
            + "in the collection " + myOperationMessageCollection.get_Input());
        Console.WriteLine("The first occurrence of operation Output " 
            + "in the collection " + myOperationMessageCollection.get_Output());
        Console.WriteLine();
    } //DisplayFlowInputOutput
} //MyOperationMessageCollectionSample 

System.Object
   System.Collections.CollectionBase
     System.Web.Services.Description.ServiceDescriptionBaseCollection
      System.Web.Services.Description.OperationMessageCollection

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

ADD
Show:
© 2014 Microsoft