This documentation is archived and is not being maintained.

OperationMessageCollection.Add Method

Adds the specified OperationMessage to the end of the OperationMessageCollection.

[Visual Basic]
Public Function Add( _
   ByVal operationMessage As OperationMessage _
) As Integer
[C#]
public int Add(
 OperationMessage operationMessage
);
[C++]
public: int Add(
 OperationMessage* operationMessage
);
[JScript]
public function Add(
   operationMessage : OperationMessage
) : int;

Parameters

operationMessage
The OperationMessage to add to the collection.

Return Value

The zero-based index where the operationMessage parameter has been added.

Example

[Visual Basic] 
' Get the operation message for the Add operation.
Dim myOperationMessage As OperationMessage = _
   myOperationMessageCollection.Item(0)
Dim myInputOperationMessage As OperationMessage = _
   CType(New OperationInput(), OperationMessage)
Dim myXmlQualifiedName As _
   New XmlQualifiedName("AddSoapIn", myDescription.TargetNamespace)
myInputOperationMessage.Message = myXmlQualifiedName

Dim myCollection(myOperationMessageCollection.Count -1 ) _
   As OperationMessage
myOperationMessageCollection.CopyTo(myCollection, 0)
Console.WriteLine("Operation name(s) :")
Dim i As Integer
For i = 0 To myCollection.Length - 1
   Console.WriteLine(" " & myCollection(i).Operation.Name)
Next i

' Add the OperationMessage to the collection.
myOperationMessageCollection.Add(myInputOperationMessage)

[C#] 
// Get the operation message for the Add operation.
OperationMessage myOperationMessage =
   myOperationMessageCollection[0];
OperationMessage myInputOperationMessage =
   (OperationMessage) new OperationInput();
XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName(
   "AddSoapIn", myDescription.TargetNamespace);
myInputOperationMessage.Message = myXmlQualifiedName;

OperationMessage[] myCollection = 
   new OperationMessage[myOperationMessageCollection.Count];
myOperationMessageCollection.CopyTo(myCollection, 0);
Console.WriteLine("Operation name(s) :");
for (int i = 0; i < myCollection.Length ; i++)
{
   Console.WriteLine(" " + myCollection[i].Operation.Name);
}

// Add the OperationMessage to the collection.
myOperationMessageCollection.Add(myInputOperationMessage);

[C++] 
// Get the operation message for the Add operation.
OperationMessage* myOperationMessage =
   myOperationMessageCollection->Item[0];
OperationMessage* myInputOperationMessage =
   dynamic_cast<OperationMessage*> (new OperationInput());
XmlQualifiedName* myXmlQualifiedName = new XmlQualifiedName(
   S"AddSoapIn", myDescription->TargetNamespace);
myInputOperationMessage->Message = myXmlQualifiedName;

OperationMessage* myCollection[] = 
   new OperationMessage*[myOperationMessageCollection->Count];
myOperationMessageCollection->CopyTo(myCollection, 0);
Console::WriteLine(S"Operation name(s) :");
for (int i = 0; i < myCollection->Length ; i++)
{
   Console::WriteLine(S" {0}", myCollection[i]->Operation->Name);
}

// Add the OperationMessage to the collection.
myOperationMessageCollection->Add(myInputOperationMessage);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

OperationMessageCollection Class | OperationMessageCollection Members | System.Web.Services.Description Namespace

Show: