次の方法で共有


Operation クラス

XML Web サービスでサポートされるアクションの抽象定義を提供します。このクラスは継承できません。

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

System.Object
   System.Web.Services.Description.DocumentableItem
      System.Web.Services.Description.Operation

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

スレッドセーフ

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

解説

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

使用例

[Visual Basic, C#, C++] Operation クラスの一般的な使用例を次に示します。この例では、HTTP POST プロトコルをサポートする PortType を持たない ServiceDescription を使用します。続いて、POST をサポートする PortType のインスタンスを追加し、新しい WSDL コントラクトを出力します。

 
Imports System
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MyOperationClass
   
   Public Shared Sub Main()
      Dim myDescription As ServiceDescription = ServiceDescription.Read("Operation_5_Input_VB.wsdl")
      ' Create a 'PortType' object.
      Dim myPortType As New PortType()
      myPortType.Name = "OperationServiceHttpPost"
      Dim myOperation As Operation = CreateOperation("AddNumbers", "s0:AddNumbersHttpPostIn", _
                                                                     "s0:AddNumbersHttpPostOut")
      myPortType.Operations.Add(myOperation)
      ' Get the PortType of the Operation. 
      Dim myPort As PortType = myOperation.PortType
        Console.WriteLine( _
           "The port type of the operation is: " & myPort.Name)
      ' Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
      myDescription.PortTypes.Add(myPortType)
      
      ' Write the 'ServiceDescription' as a WSDL file.
      myDescription.Write("Operation_5_Output_VB.wsdl")
      Console.WriteLine("WSDL file with name 'Operation_5_Output_VB.wsdl'" + _ 
                           "file created Successfully")
   End Sub 'Main
   
   Public Shared Function CreateOperation(myOperationName As String, myInputMesg As String, _
                                                         myOutputMesg As String) As Operation
      ' Create an Operation.
      Dim myOperation As New Operation()
      myOperation.Name = myOperationName
      Dim myInput As OperationMessage = _
         CType(New OperationInput(), OperationMessage)
      myInput.Message = New XmlQualifiedName(myInputMesg)
      Dim myOutput As OperationMessage = _
         CType(New OperationOutput(), OperationMessage)
      myOutput.Message = New XmlQualifiedName(myOutputMesg)

      ' Add messages to the OperationMessageCollection.
      myOperation.Messages.Add(myInput)
      myOperation.Messages.Add(myOutput)
      Console.WriteLine("Operation name is: " & myOperation.Name)
      Return myOperation
   End Function 'CreateOperation 
End Class 'MyOperationClass 

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

class MyOperationClass
{
   public static void Main()
   {
      ServiceDescription myDescription = ServiceDescription.Read("Operation_5_Input_CS.wsdl");
      // Create a 'PortType' object.
      PortType myPortType = new PortType();
      myPortType.Name = "OperationServiceHttpPost";
      Operation myOperation = CreateOperation
                         ("AddNumbers","s0:AddNumbersHttpPostIn","s0:AddNumbersHttpPostOut");    
      myPortType.Operations.Add(myOperation);
      // Get the PortType of the Operation. 
      PortType myPort = myOperation.PortType;
      Console.WriteLine(
         "The port type of the operation is: " + myPort.Name);
      // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
      myDescription.PortTypes.Add(myPortType);
      
      // Write the 'ServiceDescription' as a WSDL file.
      myDescription.Write("Operation_5_Output_CS.wsdl");
      Console.WriteLine("WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully");
   }
   public static Operation CreateOperation(string myOperationName,string myInputMesg,string myOutputMesg)
   {
      // Create an Operation.
      Operation myOperation = new Operation();
      myOperation.Name = myOperationName;
      OperationMessage myInput = (OperationMessage)new OperationInput();
      myInput.Message =  new XmlQualifiedName(myInputMesg);
      OperationMessage myOutput = (OperationMessage)new OperationOutput();
      myOutput.Message = new XmlQualifiedName(myOutputMesg);

      // Add messages to the OperationMessageCollection.
      myOperation.Messages.Add(myInput);
      myOperation.Messages.Add(myOutput);
      Console.WriteLine("Operation name is: " + myOperation.Name);     
      return myOperation;
   }
}

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

Operation* CreateOperation(String* myOperationName,String* myInputMesg,String* myOutputMesg)
{
   // Create an Operation.
   Operation* myOperation = new Operation();
   myOperation->Name = myOperationName;
   OperationMessage* myInput = dynamic_cast<OperationMessage*>(new OperationInput());
   myInput->Message =  new XmlQualifiedName(myInputMesg);
   OperationMessage* myOutput = dynamic_cast<OperationMessage*>(new OperationOutput());
   myOutput->Message = new XmlQualifiedName(myOutputMesg);

   // Add messages to the OperationMessageCollection.
   myOperation->Messages->Add(myInput);
   myOperation->Messages->Add(myOutput);
   Console::WriteLine(S"Operation name is: {0}", myOperation->Name);     
   return myOperation;
}

int main()
{
   ServiceDescription* myDescription = ServiceDescription::Read(S"Operation_5_Input_CS.wsdl");
   // Create a 'PortType' object.
   PortType* myPortType = new PortType();
   myPortType->Name = S"OperationServiceHttpPost";
   Operation* myOperation = CreateOperation
      (S"AddNumbers",S"s0:AddNumbersHttpPostIn",S"s0:AddNumbersHttpPostOut");    
   myPortType->Operations->Add(myOperation);
   // Get the PortType of the Operation. 
   PortType* myPort = myOperation->PortType;
   Console::WriteLine(
      S"The port type of the operation is: {0}", myPort->Name);
   // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
   myDescription->PortTypes->Add(myPortType);

   // Write the 'ServiceDescription' as a WSDL file.
   myDescription->Write(S"Operation_5_Output_CS.wsdl");
   Console::WriteLine(S"WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully");
}

[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 内)

参照

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