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.
System.Web.Services.Description.DocumentableItem
System.Web.Services.Description.NamedItem
System.Web.Services.Description.OperationBinding
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in System.Web.Services.dll)
The OperationBinding type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Binding | Gets the Binding of which the current OperationBinding is a member. |
![]() | Documentation | Gets or sets the text documentation for the instance of the DocumentableItem. (Inherited from DocumentableItem.) |
![]() | DocumentationElement | Gets or sets the documentation element for the DocumentableItem. (Inherited from DocumentableItem.) |
![]() | ExtensibleAttributes | Gets 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.) |
![]() | Extensions | Gets the collection of extensibility elements specific to the current OperationBinding. (Overrides DocumentableItem.Extensions.) |
![]() | Faults | Gets the FaultBindingCollection associated with the OperationBinding instance. |
![]() | Input | Gets or sets the InputBinding associated with the OperationBinding. |
![]() | Name | Gets or sets the name of the item. (Inherited from NamedItem.) |
![]() | Namespaces | Gets 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.) |
![]() | Output | Gets or sets the OutputBinding associated with the OperationBinding. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | ToString | Returns 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() { try { ServiceDescription myServiceDescription = ServiceDescription.Read("MathService_input_cs.wsdl"); 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; myInputBinding.Extensions.Add(mySoapBodyBinding); // Add the InputBinding to the OperationBinding. addOperationBinding.Input = myInputBinding; // Create an OutputBinding for the Add operation. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); // 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. addOperationBinding.Extensions.Add(mySoapOperationBinding); ServiceDescriptionFormatExtensionCollection myExtensions; // Get the FaultBindingCollection from the OperationBinding. FaultBindingCollection myFaultBindingCollection = addOperationBinding.Faults; 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; myExtensions.Add(mySoapFaultBinding); myFaultBindingCollection.Add(myFaultBinding); // Get the BindingCollection from the ServiceDescription. BindingCollection myBindingCollection = myServiceDescription.Bindings; // Get the OperationBindingCollection of SOAP binding // from the BindingCollection. OperationBindingCollection myOperationBindingCollection = myBindingCollection[0].Operations; myOperationBindingCollection.Add(addOperationBinding); Console.WriteLine( "The operations supported by this service are:"); foreach(OperationBinding myOperationBinding in myOperationBindingCollection) { Binding myBinding = myOperationBinding.Binding; Console.WriteLine(" Binding : " + myBinding.Name + " :: Name of operation : " + myOperationBinding.Name); FaultBindingCollection myFaultBindingCollection1 = myOperationBinding.Faults; foreach(FaultBinding myFaultBinding1 in myFaultBindingCollection1) { Console.WriteLine(" Fault : " + myFaultBinding1.Name); } } // Save the ServiceDescripition to an external file. myServiceDescription.Write("MathService_new_cs.wsdl"); } catch(Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
