OperationMessageCollection Class
Represents a collection of OperationInput and OperationOutput messages related to an XML Web service. This class cannot be inherited.
For a list of all members of this type, see OperationMessageCollection Members.
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
System.Web.Services.Description.OperationMessageCollection
[Visual Basic] NotInheritable Public Class OperationMessageCollection Inherits ServiceDescriptionBaseCollection [C#] public sealed class OperationMessageCollection : ServiceDescriptionBaseCollection [C++] public __gc __sealed class OperationMessageCollection : public ServiceDescriptionBaseCollection [JScript] public class OperationMessageCollection extends ServiceDescriptionBaseCollection
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
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.
Example
[Visual Basic] Imports System 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 'Main ' 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 'DisplayFlowInputOutput End Class 'MyOperationMessageCollectionSample [C#] 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(); } } [C++] #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); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.Services.Description
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web.Services (in System.Web.Services.dll)
See Also
OperationMessageCollection Members | System.Web.Services.Description Namespace