This documentation is archived and is not being maintained.

Message.FindPartsByName Method

Searches the MessagePartCollection returned by the Parts property and returns an array of type MessagePart containing the named instances.

[Visual Basic]
Public Function FindPartsByName( _
   ByVal partNames() As String _
) As MessagePart()
[C#]
public MessagePart[] FindPartsByName(
 string[] partNames
);
[C++]
public: MessagePart* FindPartsByName(
 String* partNames __gc[]
) [];
[JScript]
public function FindPartsByName(
   partNames : String[]
) : MessagePart[];

Parameters

partNames
An array of names of the MessagePart instances to be returned.

Return Value

An array of type MessagePart.

Exceptions

Exception Type Condition
ArgumentException No MessagePart instances with the specified names exist within the collection.

Example

[Visual Basic, C#, C++] The following example demonstrates the use of the FindPartsByName method.

[Visual Basic] 
' Get message from ServiceDescription.
Dim myMessage1 As Message = myServiceDescription.Messages("AddHttpPostIn")
Console.WriteLine("ServiceDescription :" + _
                  myMessage1.ServiceDescription.ToString())
Dim myParts(1) As String
myParts(0) = "a"
myParts(1) = "b"
Dim myMessageParts As MessagePart() = myMessage1.FindPartsByName(myParts)
Console.WriteLine("Results of FindPartsByName operation:")
Dim i As Integer
For i = 0 To myMessageParts.Length - 1
   Console.WriteLine("Part Name: " + myMessageParts(i).Name)
   Console.WriteLine("Part Type: " + myMessageParts(i).Type.ToString())
Next i

[C#] 
// Get message from ServiceDescription.
Message myMessage1 = myServiceDescription.Messages["AddHttpPostIn"];
Console.WriteLine("ServiceDescription :"+myMessage1.ServiceDescription);
string[] myParts = new string[2];
myParts[0] = "a";
myParts[1] = "b";
MessagePart[] myMessageParts = myMessage1.FindPartsByName(myParts);
Console.WriteLine("Results of FindPartsByName operation:");
for(int i=0;i<myMessageParts.Length; ++i)
{
   Console.WriteLine("Part Name: " +myMessageParts[i].Name);
   Console.WriteLine("Part Type: " +myMessageParts[i].Type);
}

[C++] 
// Get message from ServiceDescription.
Message* myMessage1 = myServiceDescription->Messages->Item[S"AddHttpPostIn"];
Console::WriteLine(S"ServiceDescription : {0}", myMessage1->ServiceDescription);
String* myParts[] = new String*[2];
myParts->Item[0] = S"a";
myParts->Item[1] = S"b";
MessagePart* myMessageParts[] = myMessage1->FindPartsByName(myParts);
Console::WriteLine(S"Results of FindPartsByName operation:");
for (int i=0;i<myMessageParts->Length; ++i)
{
   Console::WriteLine(S"Part Name: {0}", myMessageParts[i]->Name);
   Console::WriteLine(S"Part Type: {0}", myMessageParts[i]->Type);
}

[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

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

Show: