次の方法で共有


MessageBinding クラス

抽象コンテンツを具象形式に変換する方法を説明します。

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

System.Object
   System.Web.Services.Description.DocumentableItem
      System.Web.Services.Description.MessageBinding
         System.Web.Services.Description.FaultBinding
         System.Web.Services.Description.InputBinding
         System.Web.Services.Description.OutputBinding

MustInherit Public Class MessageBinding
   Inherits DocumentableItem
[C#]
public abstract class MessageBinding : DocumentableItem
[C++]
public __gc __abstract class MessageBinding : public
   DocumentableItem
[JScript]
public abstract class MessageBinding extends DocumentableItem

スレッドセーフ

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

解説

この抽象クラスは、次のクラスの基本クラスを形成します。

使用例

[Visual Basic, C#, C++] MessageBinding クラスの一般的な使用例を次に示します。

 
Imports System
Imports System.Web.Services.Description

Class MyClass1

   Public Shared Sub Main()
      Dim addOperationBinding As OperationBinding = _
         CreateOperationBinding("Add", "http://tempuri.org/")
   End Sub 'Main

   Public Shared Function CreateInputOutputBinding(myBindName As String, _
      isInputBinding As Boolean) As MessageBinding
      ' Value isInputBinding = true ---> return type = InputBinding.
      ' Value isInputBinding = false --> return type = OutputBinding.
      Dim myMessageBinding As MessageBinding = Nothing
      Select Case isInputBinding
         Case True
            myMessageBinding = New InputBinding()
            Console.WriteLine("Added an InputBinding")
         Case False
            myMessageBinding = New OutputBinding()
            Console.WriteLine("Added an OutputBinding")
      End Select
      myMessageBinding.Name = myBindName
      Dim mySoapBodyBinding As New SoapBodyBinding()
      mySoapBodyBinding.Use = SoapBindingUse.Literal
      myMessageBinding.Extensions.Add(mySoapBodyBinding)
      Console.WriteLine("Added extensibility element of type : " & _
         mySoapBodyBinding.GetType().ToString())
      Return myMessageBinding
   End Function 'CreateInputOutputBinding

   ' Used to create OperationBinding instances within Binding.
   Public Shared Function CreateOperationBinding(myOperation As String, _
      targetNamespace As String) As OperationBinding

      ' Create OperationBinding for operation.
      Dim myOperationBinding As New OperationBinding()
      myOperationBinding.Name = myOperation

      ' Create InputBinding for operation.
      Dim myInputBinding As InputBinding = _
         CType(CreateInputOutputBinding(Nothing, True), InputBinding)
      ' Create OutputBinding for operation.
      Dim myOutputBinding As OutputBinding = _
         CType(CreateInputOutputBinding(Nothing, False), OutputBinding)

      ' Add InputBinding and OutputBinding to OperationBinding.
      myOperationBinding.Input = myInputBinding
      myOperationBinding.Output = myOutputBinding

      ' Create an extensibility element for SoapOperationBinding.
      Dim mySoapOperationBinding As New SoapOperationBinding()
      mySoapOperationBinding.Style = SoapBindingStyle.Document
      mySoapOperationBinding.SoapAction = targetNamespace + myOperation

      ' Add the extensibility element SoapOperationBinding to OperationBinding.
      myOperationBinding.Extensions.Add(mySoapOperationBinding)
      Return myOperationBinding
   End Function 'CreateOperationBinding
End Class 'MyClass1

[C#] 
using System;
using System.Web.Services.Description;
class MyClass
{
   public static void Main()
   {
   OperationBinding addOperationBinding = 
      CreateOperationBinding("Add","http://tempuri.org/");
   }

   public static MessageBinding CreateInputOutputBinding(string myBindName,
      bool isInputBinding)
   {
     
     // Value isInputBinding = true ---> return type = InputBinding.  
     // Value isInputBinding = false --> return type = OutputBinding.
     MessageBinding myMessageBinding = null;
      switch(isInputBinding)
      {
         case true:
            myMessageBinding = new InputBinding();
            Console.WriteLine("Added an InputBinding");
            break;
         case false:
            myMessageBinding = new OutputBinding();
            Console.WriteLine("Added an OutputBinding");
            break;
      }
      myMessageBinding.Name = myBindName;
      SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
      mySoapBodyBinding.Use = SoapBindingUse.Literal;
      myMessageBinding.Extensions.Add(mySoapBodyBinding);
      Console.WriteLine("Added extensibility element of type : " + 
         mySoapBodyBinding.GetType());
      return myMessageBinding;
   }

   // Used to create OperationBinding instances within Binding.
   public static OperationBinding CreateOperationBinding(
      string myOperation,string targetNamespace)
   {
      // Create OperationBinding for Operation.
      OperationBinding myOperationBinding = new OperationBinding();
      myOperationBinding.Name = myOperation;

      // Create InputBinding for operation.
      InputBinding myInputBinding = 
        (InputBinding)CreateInputOutputBinding(null,true);

      // Create OutputBinding for operation.
      OutputBinding myOutputBinding = 
         (OutputBinding)CreateInputOutputBinding(null,false);
      
      // Add InputBinding and OutputBinding to OperationBinding. 
      myOperationBinding.Input = myInputBinding;
      myOperationBinding.Output = myOutputBinding;
      
      // Create an extensibility element for SoapOperationBinding.
      SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();
      mySoapOperationBinding.Style = SoapBindingStyle.Document;
      mySoapOperationBinding.SoapAction = targetNamespace + myOperation;

      // Add the extensibility element SoapOperationBinding to OperationBinding.
      myOperationBinding.Extensions.Add(mySoapOperationBinding);
      return myOperationBinding;
   }
}

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

MessageBinding* CreateInputOutputBinding(String* myBindName, 
   bool isInputBinding)
{

   // Value isInputBinding = true ---> return type = InputBinding.
   // Value isInputBinding = false --> return type = OutputBinding.
   MessageBinding* myMessageBinding = 0;
   switch(isInputBinding) 
   {
   case true:
      myMessageBinding = new InputBinding();
      Console::WriteLine(S"Added an InputBinding");
      break;
   case false:
      myMessageBinding = new OutputBinding();
      Console::WriteLine(S"Added an OutputBinding");
      break;
   }
   myMessageBinding->Name = myBindName;
   SoapBodyBinding* mySoapBodyBinding = new SoapBodyBinding();
   mySoapBodyBinding->Use = SoapBindingUse::Literal;
   myMessageBinding->Extensions->Add(mySoapBodyBinding);
   Console::WriteLine(S"Added extensibility element of type : {0}",
      mySoapBodyBinding->GetType());
   return myMessageBinding;
}

// Used to create OperationBinding instances within Binding.
OperationBinding* CreateOperationBinding(String* myOperation, 
   String* targetNamespace) 
{
   // Create OperationBinding for Operation.
   OperationBinding* myOperationBinding = new OperationBinding();
   myOperationBinding->Name = myOperation;

   // Create InputBinding for operation.
   InputBinding* myInputBinding = 
      dynamic_cast<InputBinding*>(CreateInputOutputBinding(0, true));

   // Create OutputBinding for operation.
   OutputBinding* myOutputBinding = 
      dynamic_cast<OutputBinding*>(CreateInputOutputBinding(0, false));

   // Add InputBinding and OutputBinding to OperationBinding.
   myOperationBinding->Input = myInputBinding;
   myOperationBinding->Output = myOutputBinding;

   // Create an extensibility element for SoapOperationBinding.
   SoapOperationBinding* mySoapOperationBinding = new SoapOperationBinding();
   mySoapOperationBinding->Style = SoapBindingStyle::Document;
   mySoapOperationBinding->SoapAction = 
      String::Concat(targetNamespace, myOperation);

   // Add the extensibility element SoapOperationBinding to OperationBinding.
   myOperationBinding->Extensions->Add(mySoapOperationBinding);
   return myOperationBinding;
}

int main() 
{
   /* OperationBinding* addOperationBinding = */
   CreateOperationBinding(S"Add", S"http://tempuri.org/");
}

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

参照

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