OperationCollection クラス

Operation クラスのインスタンスのコレクションを表します。このクラスは継承できません。

この型のすべてのメンバの一覧については、OperationCollection メンバ を参照してください。

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

NotInheritable Public Class OperationCollection
   Inherits ServiceDescriptionBaseCollection
[C#]
public sealed class OperationCollection :
   ServiceDescriptionBaseCollection
[C++]
public __gc __sealed class OperationCollection : public
   ServiceDescriptionBaseCollection
[JScript]
public class OperationCollection extends
   ServiceDescriptionBaseCollection

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

Operation クラスは、 <portType> 要素で囲まれた WSDL (Web Services Description Language) <operation> 要素に対応します。WSDL の詳細については、http://www.w3.org/TR/wsdl/ の仕様を参照してください。

使用例

[Visual Basic, C#, C++] OperationCollection クラスによって公開されるプロパティとメソッドを使用する例を次に示します。

 
Option Strict On
Imports System
Imports System.Web.Services
Imports System.Xml
Imports System.Web.Services.Description

Class MyOperationCollectionSample
   Public Shared Sub Main()
      Try
         ' Read the 'MathService_Input_vb.wsdl' file.
         Dim myDescription As ServiceDescription = _
                        ServiceDescription.Read("MathService_Input_vb.wsdl")
         Dim myPortTypeCollection As PortTypeCollection = _
                                                   myDescription.PortTypes
         ' Get the 'OperationCollection' for 'SOAP' protocol.
         Dim myOperationCollection As OperationCollection = _
                                         myPortTypeCollection(0).Operations
         Dim myOperation As New Operation()
         myOperation.Name = "Add"
         Dim myOperationMessageInput As OperationMessage = _
                              CType(New OperationInput(), OperationMessage)
         myOperationMessageInput.Message = New XmlQualifiedName _
                              ("AddSoapIn", myDescription.TargetNamespace)
         Dim myOperationMessageOutput As OperationMessage = _
                              CType(New OperationOutput(), OperationMessage)
         myOperationMessageOutput.Message = New XmlQualifiedName _
                              ("AddSoapOut", myDescription.TargetNamespace)
         myOperation.Messages.Add(myOperationMessageInput)
         myOperation.Messages.Add(myOperationMessageOutput)
         myOperationCollection.Add(myOperation)

         If myOperationCollection.Contains(myOperation) = True Then
            Console.WriteLine("The index of the added 'myOperation' " + _
                     "operation is : " + _
                     myOperationCollection.IndexOf(myOperation).ToString)
         End If

         myOperationCollection.Remove(myOperation)
         ' Insert the 'myOpearation' operation at the index '0'.
         myOperationCollection.Insert(0, myOperation)
         Console.WriteLine("The operation at index '0' is : " + _
                           myOperationCollection.Item(0).Name)

         Dim myOperationArray(myOperationCollection.Count) As Operation
         myOperationCollection.CopyTo(myOperationArray, 0)
         Console.WriteLine("The operation(s) in the collection are :")
         Dim i As Integer
         For i = 0 To myOperationCollection.Count - 1
            Console.WriteLine(" " + myOperationArray(i).Name)
         Next i

         myDescription.Write("MathService_New_vb.wsdl")
      Catch e As Exception
         Console.WriteLine("Exception caught!!!")
         Console.WriteLine("Source : " + e.Source)
         Console.WriteLine("Message : " + e.Message)
      End Try
   End Sub
End Class

[C#] 
using System;
using System.Web.Services;
using System.Xml;
using System.Web.Services.Description;

class MyOperationCollectionSample
{
   public static void Main()
   {
      try
      {
         // Read the 'MathService_Input_cs.wsdl' file.
         ServiceDescription myDescription = 
                     ServiceDescription.Read("MathService_Input_cs.wsdl");
         PortTypeCollection myPortTypeCollection =myDescription.PortTypes;
         // Get the 'OperationCollection' for 'SOAP' protocol.
         OperationCollection myOperationCollection = 
                                       myPortTypeCollection[0].Operations;
         Operation myOperation = new Operation();
         myOperation.Name = "Add";
         OperationMessage myOperationMessageInput = 
                                  (OperationMessage) new OperationInput();
         myOperationMessageInput.Message = new XmlQualifiedName
                              ("AddSoapIn",myDescription.TargetNamespace);
         OperationMessage myOperationMessageOutput = 
                                 (OperationMessage) new OperationOutput();
         myOperationMessageOutput.Message = new XmlQualifiedName(
                              "AddSoapOut",myDescription.TargetNamespace);
         myOperation.Messages.Add(myOperationMessageInput);
         myOperation.Messages.Add(myOperationMessageOutput);
         myOperationCollection.Add(myOperation);

         if(myOperationCollection.Contains(myOperation) == true)
         {
            Console.WriteLine("The index of the added 'myOperation' " +
                              "operation is : " +
                              myOperationCollection.IndexOf(myOperation));
         }

         myOperationCollection.Remove(myOperation);
         // Insert the 'myOpearation' operation at the index '0'.
         myOperationCollection.Insert(0, myOperation);
         Console.WriteLine("The operation at index '0' is : " +
                           myOperationCollection[0].Name);

         Operation[] myOperationArray = new Operation[
                                             myOperationCollection.Count];
         myOperationCollection.CopyTo(myOperationArray, 0);
         Console.WriteLine("The operation(s) in the collection are :");
         for(int i = 0; i < myOperationCollection.Count; i++)
         {
            Console.WriteLine(" " + myOperationArray[i].Name);
         }

         myDescription.Write("MathService_New_cs.wsdl");
      }
      catch(Exception e)
      {
         Console.WriteLine("Exception caught!!!");
         Console.WriteLine("Source : " + e.Source);
         Console.WriteLine("Message : " + e.Message);
      }
   }
}

[C++] 
#using <mscorlib.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Web::Services;
using namespace System::Xml;
using namespace System::Web::Services::Description;

int main()
{
   try
   {
      // Read the 'MathService_Input_cs.wsdl' file.
      ServiceDescription* myDescription =
         ServiceDescription::Read(S"MathService_Input_cs.wsdl");
      PortTypeCollection* myPortTypeCollection =myDescription->PortTypes;
      // Get the 'OperationCollection' for 'SOAP' protocol.
      OperationCollection* myOperationCollection =
         myPortTypeCollection->Item[0]->Operations;
      Operation* myOperation = new Operation();
      myOperation->Name = S"Add";
      OperationMessage* myOperationMessageInput =
         dynamic_cast<OperationMessage*> (new OperationInput());
      myOperationMessageInput->Message = new XmlQualifiedName
         (S"AddSoapIn",myDescription->TargetNamespace);
      OperationMessage* myOperationMessageOutput =
         dynamic_cast<OperationMessage*> (new OperationOutput());
      myOperationMessageOutput->Message = new XmlQualifiedName(
         S"AddSoapOut",myDescription->TargetNamespace);
      myOperation->Messages->Add(myOperationMessageInput);
      myOperation->Messages->Add(myOperationMessageOutput);
      myOperationCollection->Add(myOperation);

      if(myOperationCollection->Contains(myOperation) == true)
      {
         Console::WriteLine(S"The index of the added 'myOperation' operation is : {0}",
            __box(myOperationCollection->IndexOf(myOperation)));
      }

      myOperationCollection->Remove(myOperation);
      // Insert the 'myOpearation' operation at the index '0'.
      myOperationCollection->Insert(0, myOperation);
      Console::WriteLine(S"The operation at index '0' is : {0}", myOperationCollection->Item[0]->Name);

      Operation* myOperationArray[] = new Operation*[myOperationCollection->Count];
      myOperationCollection->CopyTo(myOperationArray, 0);
      Console::WriteLine(S"The operation(s) in the collection are :");
      for(int i = 0; i < myOperationCollection->Count; i++)
      {
         Console::WriteLine(S" {0}", myOperationArray[i]->Name);
      }

      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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Web.Services.Description

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Web.Services (System.Web.Services.dll 内)

参照

OperationCollection メンバ | System.Web.Services.Description 名前空間