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.
Assembly: System.Web.Services (in System.Web.Services.dll)
System.Web.Services.Description::DocumentableItem
System.Web.Services.Description::NamedItem
System.Web.Services.Description::OperationBinding
| Name | Description | |
|---|---|---|
![]() | OperationBinding() | Initializes a new instance of the OperationBinding class. |
| 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 the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | 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.Xml.dll> #using <System.Web.Services.dll> #using <System.dll> using namespace System; using namespace System::Web::Services::Description; int main() { try { ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_input_cs.wsdl" ); String^ myTargetNamespace = myServiceDescription->TargetNamespace; // Create an OperationBinding for the Add operation. OperationBinding^ addOperationBinding = gcnew OperationBinding; String^ addOperation = "Add"; addOperationBinding->Name = addOperation; // Create an InputBinding for the Add operation. InputBinding^ myInputBinding = gcnew InputBinding; SoapBodyBinding^ mySoapBodyBinding = gcnew 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 = gcnew OutputBinding; myOutputBinding->Extensions->Add( mySoapBodyBinding ); // Add the OutputBinding to the OperationBinding. addOperationBinding->Output = myOutputBinding; // Create an extensibility element for a SoapOperationBinding. SoapOperationBinding^ mySoapOperationBinding = gcnew SoapOperationBinding; mySoapOperationBinding->Style = SoapBindingStyle::Document; mySoapOperationBinding->SoapAction = String::Concat( 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 = gcnew FaultBinding; myFaultBinding->Name = "ErrorFloat"; // Associate SOAP fault binding to the fault binding of the operation. myExtensions = myFaultBinding->Extensions; SoapFaultBinding^ mySoapFaultBinding = gcnew 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:" ); System::Collections::IEnumerator^ myEnum = myOperationBindingCollection->GetEnumerator(); while ( myEnum->MoveNext() ) { OperationBinding^ myOperationBinding = safe_cast<OperationBinding^>(myEnum->Current); Binding^ myBinding = myOperationBinding->Binding; Console::WriteLine( " Binding : {0} :: Name of operation : {1}", myBinding->Name, myOperationBinding->Name ); FaultBindingCollection^ myFaultBindingCollection1 = myOperationBinding->Faults; System::Collections::IEnumerator^ myEnum1 = myFaultBindingCollection1->GetEnumerator(); while ( myEnum1->MoveNext() ) { FaultBinding^ myFaultBinding1 = safe_cast<FaultBinding^>(myEnum1->Current); Console::WriteLine( " Fault : {0}", myFaultBinding1->Name ); } } myServiceDescription->Write( "MathService_new_cs.wsdl" ); } catch ( Exception^ e ) { Console::WriteLine( "Exception caught!!!" ); Console::WriteLine( "Source : {0}", e->Source ); Console::WriteLine( "Message : {0}", e->Message ); } }
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

