Export (0) Print
Expand All

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 abstract class MessageBinding : NamedItem
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.

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;
   }
}

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

Community Additions

ADD
Show:
© 2014 Microsoft