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)

'Declaration
Public MustInherit Class MessageBinding
	Inherits NamedItem
'Usage
Dim instance As MessageBinding

public abstract class MessageBinding extends NamedItem
public abstract class MessageBinding extends NamedItem
Not applicable.

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

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

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

import System.*;
import System.Web.Services.Description.*;

class MyClass
{
    public static void main(String[] args) {
        OperationBinding addOperationBinding = 
            CreateOperationBinding("Add", "http://tempuri.org/");
    } //main

    public static MessageBinding CreateInputOutputBinding(String myBindName, 
        boolean isInputBinding)
    {
        // Value isInputBinding = true ---> return type = InputBinding.  
        // Value isInputBinding = false --> return type = OutputBinding.
        MessageBinding myMessageBinding = null;
        if (isInputBinding) {
            myMessageBinding = new InputBinding();
            Console.WriteLine("Added an InputBinding");
        }
        else {
            myMessageBinding = new OutputBinding();
            Console.WriteLine("Added an OutputBinding");
        }

        myMessageBinding.set_Name(myBindName);
        SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
        mySoapBodyBinding.set_Use(SoapBindingUse.Literal);
        myMessageBinding.get_Extensions().Add(mySoapBodyBinding);
        Console.WriteLine("Added extensibility element of type : " 
            + mySoapBodyBinding.GetType());

        return myMessageBinding;
    } //CreateInputOutputBinding

    // Used to create OperationBinding instances within Binding.
    public static OperationBinding CreateOperationBinding(String myOperation, 
        String targetNamespace)
    {
        // Create OperationBinding for Operation.
        OperationBinding myOperationBinding = new OperationBinding();
        myOperationBinding.set_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.set_Input(myInputBinding);
        myOperationBinding.set_Output(myOutputBinding);

        // Create an extensibility element for SoapOperationBinding.
        SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding();
        mySoapOperationBinding.set_Style(SoapBindingStyle.Document);
        mySoapOperationBinding.set_SoapAction(targetNamespace + myOperation);

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

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 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

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