通过


OperationMessageCollection 类

定义

表示与 XML Web 服务相关的集合 OperationInputOperationOutput 消息。 无法继承此类。

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
继承

示例

#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

注解

此类的实例将由父Operation级的属性返回Messages。 因此,它只能有两个成员,一个 OperationInput 成员,另一个 OperationOutput成员。

属性

名称 说明
Capacity

获取或设置可包含的元素 CollectionBase 数。

(继承自 CollectionBase)
Count

获取实例中包含的 CollectionBase 元素数。 无法重写此属性。

(继承自 CollectionBase)
Flow

获取 支持的 OperationMessageCollection传输类型。

InnerList

获取包含 ArrayList 实例中 CollectionBase 元素的列表。

(继承自 CollectionBase)
Input

获取集合中第一个 OperationInput 匹配项。

Item[Int32]

获取或设置指定从零开始的索引处的值 OperationMessage

List

获取包含 IList 实例中 CollectionBase 元素的列表。

(继承自 CollectionBase)
Output

获取集合中第一个 OperationOutput 匹配项。

Table

获取一个接口,该接口实现键和值在 . 中的 ServiceDescriptionBaseCollection关联。

(继承自 ServiceDescriptionBaseCollection)

方法

名称 说明
Add(OperationMessage)

将指定的 OperationMessage 值添加到末尾 OperationMessageCollection

Clear()

CollectionBase 实例中删除所有对象。 无法重写此方法。

(继承自 CollectionBase)
Contains(OperationMessage)

确定指定的 OperationMessage 是否为 . 的成员 OperationMessageCollection

CopyTo(OperationMessage[], Int32)

将整个对象 OperationMessageCollection 复制到一 OperationMessage个兼容的一维数组,从目标数组的指定从零开始的索引处开始。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetEnumerator()

返回循环访问实例的 CollectionBase 枚举数。

(继承自 CollectionBase)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetKey(Object)

返回与引用传递的值关联的键的名称。

(继承自 ServiceDescriptionBaseCollection)
GetType()

获取当前实例的 Type

(继承自 Object)
IndexOf(OperationMessage)

搜索指定的 OperationMessage 并返回集合中第一个匹配项的从零开始的索引。

Insert(Int32, OperationMessage)

将指定的 OperationMessage 索引添加到 OperationMessageCollection 指定的从零开始的索引处。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
OnClear()

清除 ServiceDescriptionBaseCollection 实例的内容。

(继承自 ServiceDescriptionBaseCollection)
OnClearComplete()

清除实例的内容 CollectionBase 后,执行其他自定义进程。

(继承自 CollectionBase)
OnInsert(Int32, Object)

在将新元素 CollectionBase 插入实例之前执行其他自定义过程。

(继承自 CollectionBase)
OnInsertComplete(Int32, Object)

将新元素插入新元素 ServiceDescriptionBaseCollection后执行其他自定义过程。

(继承自 ServiceDescriptionBaseCollection)
OnRemove(Int32, Object)

从 . ServiceDescriptionBaseCollection. 中删除元素

(继承自 ServiceDescriptionBaseCollection)
OnRemoveComplete(Int32, Object)

CollectionBase 实例中删除元素后执行其他自定义进程。

(继承自 CollectionBase)
OnSet(Int32, Object, Object)

在 . 中 ServiceDescriptionBaseCollection将一个值替换为另一个值。

(继承自 ServiceDescriptionBaseCollection)
OnSetComplete(Int32, Object, Object)

在实例中 CollectionBase 设置值后执行其他自定义进程。

(继承自 CollectionBase)
OnValidate(Object)

验证值时执行其他自定义进程。

(继承自 CollectionBase)
Remove(OperationMessage)

中移除指定的第一个匹配项。

RemoveAt(Int32)

删除实例的指定索引处的 CollectionBase 元素。 此方法不可重写。

(继承自 CollectionBase)
SetParent(Object, Object)

设置实例的 ServiceDescriptionBaseCollection 父对象。

(继承自 ServiceDescriptionBaseCollection)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
ICollection.CopyTo(Array, Int32)

将整个 CollectionBase 复制到兼容的一维 Array,从目标数组的指定索引处开始。

(继承自 CollectionBase)
ICollection.IsSynchronized

获取一个值,该值指示对 CollectionBase 同步的访问是否同步(线程安全)。

(继承自 CollectionBase)
ICollection.SyncRoot

获取可用于同步对 . CollectionBase的访问的对象。

(继承自 CollectionBase)
IList.Add(Object)

将对象添加到该 CollectionBase对象的末尾。

(继承自 CollectionBase)
IList.Contains(Object)

确定该元素是否 CollectionBase 包含特定元素。

(继承自 CollectionBase)
IList.IndexOf(Object)

搜索指定的 Object 并返回整个 CollectionBase匹配项中第一个匹配项的从零开始的索引。

(继承自 CollectionBase)
IList.Insert(Int32, Object)

将元素 CollectionBase 插入指定索引处。

(继承自 CollectionBase)
IList.IsFixedSize

获取一个值,该值指示是否 CollectionBase 具有固定大小。

(继承自 CollectionBase)
IList.IsReadOnly

获取一个值,该值指示是否 CollectionBase 为只读。

(继承自 CollectionBase)
IList.Item[Int32]

获取或设置指定索引处的元素。

(继承自 CollectionBase)
IList.Remove(Object)

从中 CollectionBase删除特定对象的第一个匹配项。

(继承自 CollectionBase)

扩展方法

名称 说明
AsParallel(IEnumerable)

启用查询的并行化。

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定类型。

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。

适用于