本文整理汇总了C#中System.Web.Services.Description.MessagePartCollection类的典型用法代码示例。如果您正苦于以下问题:C# MessagePartCollection类的具体用法?C# MessagePartCollection怎么用?C# MessagePartCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessagePartCollection类属于System.Web.Services.Description命名空间,在下文中一共展示了MessagePartCollection类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;
class MyClass1
{
public static void Main()
{
Console.WriteLine("");
Console.WriteLine("MessagePartCollection Sample");
Console.WriteLine("============================");
Console.WriteLine("");
ServiceDescription myServiceDescription =
ServiceDescription.Read("MathService.wsdl");
// Get the message collection.
MessageCollection myMessageCollection = myServiceDescription.Messages;
Console.WriteLine("Total Messages in the document = " +
myServiceDescription.Messages.Count);
Console.WriteLine("");
Console.WriteLine("Enumerating PartCollection for each message...");
Console.WriteLine("");
// Get the message part collection for each message.
for(int i =0; i < myMessageCollection.Count; ++i)
{
Console.WriteLine("Message : " + myMessageCollection[i].Name);
// Get the message part collection.
MessagePartCollection myMessagePartCollection =
myMessageCollection[i].Parts;
// Display the part collection.
for(int k = 0; k < myMessagePartCollection.Count;k++)
{
Console.WriteLine("\t Part Name : " +
myMessagePartCollection[k].Name);
Console.WriteLine("\t Message Name : " +
myMessagePartCollection[k].Message.Name);
}
Console.WriteLine("");
}
Console.WriteLine("Displaying the array copied from the " +
"MessagePartCollection for the message AddHttpGetIn.");
Message myLocalMessage = myServiceDescription.Messages["AddHttpPostOut"];
if (myMessageCollection.Contains(myLocalMessage))
{
Console.WriteLine("Message : " + myLocalMessage.Name);
// Get the message part collection.
MessagePartCollection myMessagePartCollection = myLocalMessage.Parts;
MessagePart[] myMessagePart =
new MessagePart[myMessagePartCollection.Count];
// Copy the MessagePartCollection to an array.
myMessagePartCollection.CopyTo(myMessagePart,0);
for(int k = 0; k < myMessagePart.Length; k++)
{
Console.WriteLine("\t Part Name : " +
myMessagePartCollection[k].Name);
}
Console.WriteLine("");
}
Console.WriteLine("Checking if message is AddHttpPostOut...");
Message myMessage = myServiceDescription.Messages["AddHttpPostOut"];
if (myMessageCollection.Contains(myMessage))
{
// Get the message part collection.
MessagePartCollection myMessagePartCollection = myMessage.Parts;
// Get the part named Body.
MessagePart myMessagePart = myMessage.Parts["Body"];
if (myMessagePartCollection.Contains(myMessagePart))
{
// Get the index of the part named Body.
Console.WriteLine("Index of Body in MessagePart collection = " +
myMessagePartCollection.IndexOf(myMessagePart));
Console.WriteLine("Deleting Body from MessagePart collection...");
myMessagePartCollection.Remove(myMessagePart);
if(myMessagePartCollection.IndexOf(myMessagePart)== -1)
{
Console.WriteLine("MessagePart Body successfully deleted " +
"from the message AddHttpPostOut.");
}
}
}
}
}
开发者ID:.NET开发者,项目名称:System.Web.Services.Description,代码行数:91,代码来源:MessagePartCollection
注:本文中的System.Web.Services.Description.MessagePartCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论