This documentation is archived and is not being maintained.

MessageBinding Class

Describes how abstract content is mapped into a concrete format.

Namespace:  System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

public ref class MessageBinding abstract : public NamedItem

This abstract class forms the base class for the following classes:

The following example demonstrates a typical use of the MessageBinding class.

#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 <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/");
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: