Message.FindPartByName(String) 方法
定义
搜索由 MessagePartCollection 属性返回的 Parts,并返回已命名的 MessagePart。Searches the MessagePartCollection returned by the Parts property, and returns the named MessagePart.
public:
System::Web::Services::Description::MessagePart ^ FindPartByName(System::String ^ partName);
public System.Web.Services.Description.MessagePart FindPartByName (string partName);
member this.FindPartByName : string -> System.Web.Services.Description.MessagePart
Public Function FindPartByName (partName As String) As MessagePart
参数
- partName
- String
命名要返回的 MessagePart 的字符串。A string that names the MessagePart to be returned.
返回
例外
集合中不存在具有指定名称的 MessagePart。No MessagePart with the specified name exists within the collection.
示例
下面的示例演示 FindPartByName 方法的用法。The following example demonstrates the use of the FindPartByName method.
// Get another message from ServiceDescription.
Message^ myMessage2 = myServiceDescription->Messages[ "DivideHttpGetOut" ];
MessagePart^ myMessagePart = myMessage2->FindPartByName( "Body" );
Console::WriteLine( "Results of FindPartByName operation:" );
Console::WriteLine( "Part Name: {0}", myMessagePart->Name );
Console::WriteLine( "Part Element: {0}", myMessagePart->Element );
// Get another message from ServiceDescription.
Message myMessage2 = myServiceDescription.Messages["DivideHttpGetOut"];
MessagePart myMessagePart=myMessage2.FindPartByName("Body");
Console.WriteLine("Results of FindPartByName operation:");
Console.WriteLine("Part Name: " +myMessagePart.Name);
Console.WriteLine("Part Element: " +myMessagePart.Element);
' Get another message from ServiceDescription.
Dim myMessage2 As Message = myServiceDescription.Messages("DivideHttpGetOut")
Dim myMessagePart As MessagePart = myMessage2.FindPartByName("Body")
Console.WriteLine("Results of FindPartByName operation:")
Console.WriteLine("Part Name: " + myMessagePart.Name)
Console.WriteLine("Part Element: " + myMessagePart.Element.ToString())