BindingCollection.Insert Method (Int32, Binding)


Adds the specified Binding to the BindingCollection at the specified zero-based index.

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

public void Insert(
	int index,
	Binding binding


Type: System.Int32

The zero-based index at which to insert the binding parameter.

Type: System.Web.Services.Description.Binding

The Binding to be added to the collection.

If the number of items in the collection already equals the collection's capacity, the capacity is doubled by automatically reallocating the internal array before the new element is inserted.

If the index parameter is equal to Count, the binding parameter is added to the end of the BindingCollection.

The elements after the insertion point move down to accommodate the new element.

// Create a new Binding for SOAP Protocol.
Binding myBinding = new Binding();
myBinding.Name = myServiceDescription.Services[0].Name + "Soap";
// Pass the name of the existing porttype 'MathServiceSoap' and the Xml targetNamespace attribute of the Descriptions tag.
myBinding.Type = new XmlQualifiedName("MathServiceSoap",myServiceDescription.TargetNamespace);
// Create SOAP Extensibility element.
SoapBinding mySoapBinding = new SoapBinding();
// SOAP over HTTP.
mySoapBinding.Transport = "";
mySoapBinding.Style = SoapBindingStyle.Document;
// Add tag soap:binding as an extensibility element.
// Create OperationBindings for each of the operations defined in asmx file.
OperationBinding addOperationBinding = CreateOperationBinding("Add",myServiceDescription.TargetNamespace);
OperationBinding subtractOperationBinding = CreateOperationBinding("Subtract",myServiceDescription.TargetNamespace);
OperationBinding multiplyOperationBinding = CreateOperationBinding("Multiply",myServiceDescription.TargetNamespace);
OperationBinding divideOperationBinding = CreateOperationBinding("Divide",myServiceDescription.TargetNamespace);

.NET Framework
Available since 1.1
Return to top