Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
OperationBinding Class
Collapse the table of content
Expand the table of content

OperationBinding Class

Provides specifications for protocols and data formats for the messages used in the action supported by the XML Web service. This class cannot be inherited.

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

public sealed class OperationBinding : NamedItem

The OperationBinding type exposes the following members.

Public methodOperationBindingInitializes a new instance of the OperationBinding class.

Public propertyBindingGets the Binding of which the current OperationBinding is a member.
Public propertyDocumentationGets or sets the text documentation for the instance of the DocumentableItem. (Inherited from DocumentableItem.)
Public propertyDocumentationElementGets or sets the documentation element for the DocumentableItem. (Inherited from DocumentableItem.)
Public propertyExtensibleAttributesGets or sets an array of type XmlAttribute that represents attribute extensions of WSDL to comply with Web Services Interoperability (WS-I) Basic Profile 1.1. (Inherited from DocumentableItem.)
Public propertyExtensionsGets the collection of extensibility elements specific to the current OperationBinding. (Overrides DocumentableItem.Extensions.)
Public propertyFaultsGets the FaultBindingCollection associated with the OperationBinding instance.
Public propertyInputGets or sets the InputBinding associated with the OperationBinding.
Public propertyNameGets or sets the name of the item. (Inherited from NamedItem.)
Public propertyNamespacesGets or sets the dictionary of namespace prefixes and namespaces used to preserve namespace prefixes and namespaces when a ServiceDescription object is constructed. (Inherited from DocumentableItem.)
Public propertyOutputGets or sets the OutputBinding associated with the OperationBinding.

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The OperationBinding class corresponds to the Web Services Description Language (WSDL) <operation> element enclosed by the <binding> element, which in turn corresponds to the Binding class. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.

The following example demonstrates the use of the properties and methods exposed by the OperationBinding class. It takes an existing ServiceDescription and adds support for the SOAP protocol.

using System;
using System.Web.Services.Description;

class MyOperationBindingSample
   static void Main()
         ServiceDescription myServiceDescription =
         string myTargetNamespace = myServiceDescription.TargetNamespace;

         // Create an OperationBinding for the Add operation.
         OperationBinding addOperationBinding = new OperationBinding();
         string addOperation = "Add";
         addOperationBinding.Name = addOperation;

         // Create an InputBinding for the Add operation.
         InputBinding myInputBinding = new InputBinding();
         SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding();
         mySoapBodyBinding.Use = SoapBindingUse.Literal;

         // Add the InputBinding to the OperationBinding.
         addOperationBinding.Input = myInputBinding;

         // Create an OutputBinding for the Add operation.
         OutputBinding myOutputBinding = new OutputBinding();

         // Add the OutputBinding to the OperationBinding. 
         addOperationBinding.Output = myOutputBinding;

         // Create an extensibility element for a SoapOperationBinding.
         SoapOperationBinding mySoapOperationBinding = 
            new SoapOperationBinding();
         mySoapOperationBinding.Style = SoapBindingStyle.Document;
         mySoapOperationBinding.SoapAction = myTargetNamespace + addOperation;

         // Add the extensibility element SoapOperationBinding to  
         // the OperationBinding.

         ServiceDescriptionFormatExtensionCollection myExtensions;

         // Get the FaultBindingCollection from the OperationBinding.
         FaultBindingCollection myFaultBindingCollection =
         FaultBinding myFaultBinding = new FaultBinding();
         myFaultBinding.Name = "ErrorFloat";

         // Associate SOAP fault binding to the fault binding of the operation.
         myExtensions = myFaultBinding.Extensions;
         SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding();
         mySoapFaultBinding.Use = SoapBindingUse.Literal;
         mySoapFaultBinding.Namespace = myTargetNamespace;

         // Get the BindingCollection from the ServiceDescription.
         BindingCollection myBindingCollection = 

         // Get the OperationBindingCollection of SOAP binding  
         // from the BindingCollection.
         OperationBindingCollection myOperationBindingCollection = 

            "The operations supported by this service are:");
         foreach(OperationBinding myOperationBinding in 
            Binding myBinding = myOperationBinding.Binding;
            Console.WriteLine(" Binding : " + myBinding.Name +
               " :: Name of operation : " + myOperationBinding.Name);
            FaultBindingCollection myFaultBindingCollection1 = 
            foreach(FaultBinding myFaultBinding1 in 
                 Console.WriteLine("    Fault : " + myFaultBinding1.Name);
         // Save the ServiceDescripition to an external file.
      catch(Exception e)
         Console.WriteLine("Exception caught!!!");
         Console.WriteLine("Source : " + e.Source);
         Console.WriteLine("Message : " + e.Message);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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