OperationInput クラス

XML Web サービスで受信する入力メッセージの仕様を定義します。このクラスは継承できません。

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

System.Object
   System.Web.Services.Description.DocumentableItem
      System.Web.Services.Description.OperationMessage
         System.Web.Services.Description.OperationInput

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

スレッドセーフ

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

解説

このクラスの 1 つのインスタンスだけが、親 Operation インスタンスの Messages プロパティのメンバになります。

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

使用例

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

Class MyOperationInputSample
   Public Shared Sub Main()
      Try
         Dim myDescription As ServiceDescription = _
            ServiceDescription.Read("AddNumbersIn_vb.wsdl")

         ' Add the ServiceHttpPost binding.
         Dim myBinding As New Binding()
         myBinding.Name = "ServiceHttpPost"
         Dim myXmlQualifiedName As New XmlQualifiedName("s0:ServiceHttpPost")
         myBinding.Type = myXmlQualifiedName
         Dim myHttpBinding As New HttpBinding()
         myHttpBinding.Verb = "POST"
         myBinding.Extensions.Add(myHttpBinding)

         ' Add the operation name AddNumbers.
         Dim myOperationBinding As New OperationBinding()
         myOperationBinding.Name = "AddNumbers"
         Dim myOperation As New HttpOperationBinding()
         myOperation.Location = "/AddNumbers"
         myOperationBinding.Extensions.Add(myOperation)

         ' Add the input binding.
         Dim myInput As New InputBinding()
         Dim postMimeContentbinding As New MimeContentBinding()
         postMimeContentbinding.Type = "application/x-www-form-urlencoded"
         myInput.Extensions.Add(postMimeContentbinding)

         ' Add the InputBinding to the OperationBinding.
         myOperationBinding.Input = myInput

         ' Add the ouput binding.
         Dim myOutput As New OutputBinding()
         Dim postMimeXmlBinding As New MimeXmlBinding()
         postMimeXmlBinding.Part = "Body"
         myOutput.Extensions.Add(postMimeXmlBinding)

         ' Add the OutputBinding to the OperationBinding.
         myOperationBinding.Output = myOutput

         myBinding.Operations.Add(myOperationBinding)
         myDescription.Bindings.Add(myBinding)

         ' Add the port definition.
         Dim postPort As New Port()
         postPort.Name = "ServiceHttpPost"
         postPort.Binding = New XmlQualifiedName("s0:ServiceHttpPost")
         Dim postAddressBinding As New HttpAddressBinding()
         postAddressBinding.Location = "https://localhost/Service.vb.asmx"
         postPort.Extensions.Add(postAddressBinding)
         myDescription.Services(0).Ports.Add(postPort)

         ' Add the post port type definition.
         Dim postPortType As New PortType()
         postPortType.Name = "ServiceHttpPost"
         Dim postOperation As New Operation()
         postOperation.Name = "AddNumbers"
         Dim postOutput As OperationMessage = _
            CType(New OperationOutput(), OperationMessage)
         postOutput.Message = New XmlQualifiedName("s0:AddNumbersHttpPostOut")

         Dim postInput As New OperationInput()
         postInput.Message = New XmlQualifiedName("s0:AddNumbersHttpPostIn")

         postOperation.Messages.Add(postInput)
         postOperation.Messages.Add(postOutput)
         postPortType.Operations.Add(postOperation)

         myDescription.PortTypes.Add(postPortType)

         ' Add the first message information.
         Dim postMessage1 As New Message()
         postMessage1.Name = "AddNumbersHttpPostIn"
         Dim postMessagePart1 As New MessagePart()
         postMessagePart1.Name = "firstnumber"
         postMessagePart1.Type = New XmlQualifiedName("s:string")

         ' Add the second message information.
         Dim postMessagePart2 As New MessagePart()
         postMessagePart2.Name = "secondnumber"
         postMessagePart2.Type = New XmlQualifiedName("s:string")
         postMessage1.Parts.Add(postMessagePart1)
         postMessage1.Parts.Add(postMessagePart2)
         Dim postMessage2 As New Message()
         postMessage2.Name = "AddNumbersHttpPostOut"

         ' Add the third message information.
         Dim postMessagePart3 As New MessagePart()
         postMessagePart3.Name = "Body"
         postMessagePart3.Element = New XmlQualifiedName("s0:int")
         postMessage2.Parts.Add(postMessagePart3)

         myDescription.Messages.Add(postMessage1)
         myDescription.Messages.Add(postMessage2)

         ' Write the ServiceDescription as a WSDL file.
         myDescription.Write("AddNumbersOut_vb.wsdl")
         Console.WriteLine("WSDL file named AddNumberOut_vb.Wsdl" & _
            " created successfully.")
      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.Description;
using System.Collections;
using System.Xml;

class MyOperationInputSample
{
   public static void Main()
   {
      try
      {
         ServiceDescription myDescription = 
            ServiceDescription.Read("AddNumbersIn_cs.wsdl");

         // Add the ServiceHttpPost binding.
         Binding myBinding = new Binding();
         myBinding.Name = "ServiceHttpPost";
         XmlQualifiedName myXmlQualifiedName = 
            new XmlQualifiedName ("s0:ServiceHttpPost");
         myBinding.Type = myXmlQualifiedName;
         HttpBinding myHttpBinding = new HttpBinding();
         myHttpBinding.Verb = "POST";
         myBinding.Extensions.Add(myHttpBinding);

         // Add the operation name AddNumbers.
         OperationBinding myOperationBinding = new OperationBinding();
         myOperationBinding.Name = "AddNumbers";
         HttpOperationBinding myOperation = new HttpOperationBinding();
         myOperation.Location = "/AddNumbers";
         myOperationBinding.Extensions.Add(myOperation);

         // Add the input binding.
         InputBinding myInput = new InputBinding();
         MimeContentBinding postMimeContentbinding = 
           new MimeContentBinding();
         postMimeContentbinding.Type= "application/x-www-form-urlencoded";
         myInput.Extensions.Add(postMimeContentbinding);

         // Add the InputBinding to the OperationBinding.
         myOperationBinding.Input = myInput;

         // Add the ouput binding.
         OutputBinding myOutput = new OutputBinding();
         MimeXmlBinding postMimeXmlBinding = new MimeXmlBinding();
         postMimeXmlBinding.Part= "Body";
         myOutput.Extensions.Add(postMimeXmlBinding);

         // Add the OutputBinding to the OperationBinding.
         myOperationBinding.Output = myOutput; 

         myBinding.Operations.Add(myOperationBinding);
         myDescription.Bindings.Add(myBinding);

         // Add the port definition.
         Port postPort = new Port();
         postPort.Name = "ServiceHttpPost";
         postPort.Binding = new XmlQualifiedName("s0:ServiceHttpPost");
         HttpAddressBinding postAddressBinding = new HttpAddressBinding();
         postAddressBinding.Location = "https://localhost/Service.cs.asmx";
         postPort.Extensions.Add(postAddressBinding);
         myDescription.Services[0].Ports.Add(postPort);

         // Add the post port type definition.
         PortType postPortType = new PortType();
         postPortType.Name = "ServiceHttpPost";
         Operation postOperation = new Operation();
         postOperation.Name = "AddNumbers";
         OperationMessage postOutput = 
            (OperationMessage)new OperationOutput();
         postOutput.Message = 
            new XmlQualifiedName ("s0:AddNumbersHttpPostOut");
         OperationInput postInput = new OperationInput();
         postInput.Message = 
            new XmlQualifiedName ("s0:AddNumbersHttpPostIn");

         postOperation.Messages.Add(postInput);
         postOperation.Messages.Add(postOutput);
         postPortType.Operations.Add(postOperation);
         myDescription.PortTypes.Add(postPortType);

         // Add the first message information.
         Message postMessage1 = new Message();
         postMessage1.Name="AddNumbersHttpPostIn";
         MessagePart postMessagePart1 = new MessagePart();
         postMessagePart1.Name = "firstnumber";
         postMessagePart1.Type = new XmlQualifiedName("s:string");

         // Add the second message information.
         MessagePart postMessagePart2 = new MessagePart();
         postMessagePart2.Name = "secondnumber";
         postMessagePart2.Type = new XmlQualifiedName("s:string");
         postMessage1.Parts.Add(postMessagePart1);
         postMessage1.Parts.Add(postMessagePart2);
         Message postMessage2 = new Message();
         postMessage2.Name = "AddNumbersHttpPostOut";

         // Add the third message information.
         MessagePart postMessagePart3 = new MessagePart();
         postMessagePart3.Name = "Body";
         postMessagePart3.Element = new XmlQualifiedName("s0:int");
         postMessage2.Parts.Add(postMessagePart3); 

         myDescription.Messages.Add(postMessage1);
         myDescription.Messages.Add(postMessage2);

         // Write the ServiceDescription as a WSDL file.
         myDescription.Write("AddNumbersOut_cs.wsdl");
         Console.WriteLine("WSDL file named AddNumberOut_cs.Wsdl" +
            " created successfully.");
      }
      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 <System.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;

int main()
{
   try
   {
      ServiceDescription* myDescription = 
         ServiceDescription::Read(S"AddNumbersIn_cs.wsdl");

      // Add the ServiceHttpPost binding.
      Binding* myBinding = new Binding();
      myBinding->Name = S"ServiceHttpPost";
      XmlQualifiedName* myXmlQualifiedName = 
         new XmlQualifiedName (S"s0:ServiceHttpPost");
      myBinding->Type = myXmlQualifiedName;
      HttpBinding* myHttpBinding = new HttpBinding();
      myHttpBinding->Verb = S"POST";
      myBinding->Extensions->Add(myHttpBinding);

      // Add the operation name AddNumbers.
      OperationBinding* myOperationBinding = new OperationBinding();
      myOperationBinding->Name = S"AddNumbers";
      HttpOperationBinding* myOperation = new HttpOperationBinding();
      myOperation->Location = S"/AddNumbers";
      myOperationBinding->Extensions->Add(myOperation);

      // Add the input binding.
      InputBinding* myInput = new InputBinding();
      MimeContentBinding* postMimeContentbinding = 
         new MimeContentBinding();
      postMimeContentbinding->Type= S"application/x-www-form-urlencoded";
      myInput->Extensions->Add(postMimeContentbinding);

      // Add the InputBinding to the OperationBinding.
      myOperationBinding->Input = myInput;

      // Add the ouput binding.
      OutputBinding* myOutput = new OutputBinding();
      MimeXmlBinding* postMimeXmlBinding = new MimeXmlBinding();
      postMimeXmlBinding->Part= S"Body";
      myOutput->Extensions->Add(postMimeXmlBinding);

      // Add the OutputBinding to the OperationBinding.
      myOperationBinding->Output = myOutput; 

      myBinding->Operations->Add(myOperationBinding);
      myDescription->Bindings->Add(myBinding);

      // Add the port definition.
      Port* postPort = new Port();
      postPort->Name = S"ServiceHttpPost";
      postPort->Binding = new XmlQualifiedName(S"s0:ServiceHttpPost");
      HttpAddressBinding* postAddressBinding = new HttpAddressBinding();
      postAddressBinding->Location = S"https://localhost/Service.cs.asmx";
      postPort->Extensions->Add(postAddressBinding);
      myDescription->Services->Item[0]->Ports->Add(postPort);

      // Add the post port type definition.
      PortType* postPortType = new PortType();
      postPortType->Name = S"ServiceHttpPost";
      Operation* postOperation = new Operation();
      postOperation->Name = S"AddNumbers";
      OperationMessage* postOutput = 
         dynamic_cast<OperationMessage*>(new OperationOutput());
      postOutput->Message = 
         new XmlQualifiedName (S"s0:AddNumbersHttpPostOut");
      OperationInput* postInput = new OperationInput();
      postInput->Message = 
         new XmlQualifiedName (S"s0:AddNumbersHttpPostIn");

      postOperation->Messages->Add(postInput);
      postOperation->Messages->Add(postOutput);
      postPortType->Operations->Add(postOperation);
      myDescription->PortTypes->Add(postPortType);

      // Add the first message information.
      Message* postMessage1 = new Message();
      postMessage1->Name=S"AddNumbersHttpPostIn";
      MessagePart* postMessagePart1 = new MessagePart();
      postMessagePart1->Name = S"firstnumber";
      postMessagePart1->Type = new XmlQualifiedName(S"s:string");

      // Add the second message information.
      MessagePart* postMessagePart2 = new MessagePart();
      postMessagePart2->Name = S"secondnumber";
      postMessagePart2->Type = new XmlQualifiedName(S"s:string");
      postMessage1->Parts->Add(postMessagePart1);
      postMessage1->Parts->Add(postMessagePart2);
      Message* postMessage2 = new Message();
      postMessage2->Name = S"AddNumbersHttpPostOut";

      // Add the third message information.
      MessagePart* postMessagePart3 = new MessagePart();
      postMessagePart3->Name = S"Body";
      postMessagePart3->Element = new XmlQualifiedName(S"s0:int");
      postMessage2->Parts->Add(postMessagePart3); 

      myDescription->Messages->Add(postMessage1);
      myDescription->Messages->Add(postMessage2);

      // Write the ServiceDescription as a WSDL file.
      myDescription->Write(S"AddNumbersOut_cs.wsdl");
      Console::WriteLine(S"WSDL file named AddNumberOut_cs.Wsdl" 
         S" created successfully.");
   }
   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 内)

参照

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