MessageBinding 类

定义

描述如何将抽象内容映射到具体格式。

public ref class MessageBinding abstract : System::Web::Services::Description::DocumentableItem
public ref class MessageBinding abstract : System::Web::Services::Description::NamedItem
public abstract class MessageBinding : System.Web.Services.Description.DocumentableItem
public abstract class MessageBinding : System.Web.Services.Description.NamedItem
type MessageBinding = class
    inherit DocumentableItem
type MessageBinding = class
    inherit NamedItem
Public MustInherit Class MessageBinding
Inherits DocumentableItem
Public MustInherit Class MessageBinding
Inherits NamedItem
继承
MessageBinding
继承
派生

示例

以下示例演示类 MessageBinding 的典型用法。

#using <System.dll>
#using <System.Xml.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 = nullptr;
   switch ( isInputBinding )
   {
      case true:
         myMessageBinding = gcnew InputBinding;
         Console::WriteLine( "Added an InputBinding" );
         break;

      case false:
         myMessageBinding = gcnew OutputBinding;
         Console::WriteLine( "Added an OutputBinding" );
         break;
   }
   myMessageBinding->Name = myBindName;
   SoapBodyBinding^ mySoapBodyBinding = gcnew SoapBodyBinding;
   mySoapBodyBinding->Use = SoapBindingUse::Literal;
   myMessageBinding->Extensions->Add( mySoapBodyBinding );
   Console::WriteLine( "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 = gcnew OperationBinding;
   myOperationBinding->Name = myOperation;

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

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

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

   // Create an extensibility element for SoapOperationBinding.
   SoapOperationBinding^ mySoapOperationBinding = gcnew 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( "Add", "http://tempuri.org/" );
}
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;
   }
}
Imports System.Web.Services.Description

Class MyClass1

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

   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

注解

此抽象类构成以下类的基类:

构造函数

MessageBinding()

初始化 MessageBinding 类的新实例。

属性

Documentation

获取或设置 DocumentableItem 的实例的文本文档。

(继承自 DocumentableItem)
DocumentationElement

获取或设置 DocumentableItem 的文档元素。

(继承自 DocumentableItem)
ExtensibleAttributes

获取或设置类型为 XmlAttribute 的数组,该数组表示为符合 Web 服务互操作性 (WS-I) 基本概要 1.1 而进行的 WSDL 特性扩展。

(继承自 DocumentableItem)
Extensions

获取与 ServiceDescriptionFormatExtensionCollection 关联的 DocumentableItem

Extensions

获取与此 ServiceDescriptionFormatExtensionCollection 关联的 DocumentableItem

(继承自 DocumentableItem)
Name

获取或设置 MessageBinding 的名称。

Name

获取或设置项的名称。

(继承自 NamedItem)
Namespaces

获取或设置命名空间前缀和命名空间的字典,该字典用于在构造 ServiceDescription 对象时,保留命名空间的前缀和命名空间。

(继承自 DocumentableItem)
OperationBinding

获取当前 OperationBinding 为其成员的 MessageBinding

方法

Equals(Object)

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

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

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

(继承自 Object)

适用于