This documentation is archived and is not being maintained.

BindingCollection::Insert Method

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
)

Parameters

index
Type: System::Int32

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

binding
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 = gcnew Binding;
myBinding->Name = String::Concat( myServiceDescription->Services->default[ 0 ]->Name, "Soap" );

// Pass the name of the existing porttype 'MathServiceSoap' and the Xml targetNamespace attribute of the Descriptions tag.
myBinding->Type = gcnew XmlQualifiedName( "MathServiceSoap",myServiceDescription->TargetNamespace );

// Create SOAP Extensibility element.
SoapBinding^ mySoapBinding = gcnew SoapBinding;
// SOAP over HTTP.
mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http";
mySoapBinding->Style = SoapBindingStyle::Document;
// Add tag soap:binding as an extensibility element.
myBinding->Extensions->Add( mySoapBinding );

// Create OperationBindings for each of the operations defined in asmx file.
OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( addOperationBinding );
OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( subtractOperationBinding );
OperationBinding^ multiplyOperationBinding = CreateOperationBinding( "Multiply", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( multiplyOperationBinding );
OperationBinding^ divideOperationBinding = CreateOperationBinding( "Divide", myServiceDescription->TargetNamespace );
myBinding->Operations->Add( divideOperationBinding );

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: