OperationMessageCollection クラス
XML Web サービスに関連する OperationInput メッセージと OperationOutput メッセージのコレクションを表します。このクラスは継承できません。
この型のすべてのメンバの一覧については、OperationMessageCollection メンバ を参照してください。
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
System.Web.Services.Description.OperationMessageCollection
NotInheritable Public Class OperationMessageCollection
Inherits ServiceDescriptionBaseCollection
[C#]
public sealed class OperationMessageCollection :
ServiceDescriptionBaseCollection
[C++]
public __gc __sealed class OperationMessageCollection : public
ServiceDescriptionBaseCollection
[JScript]
public class OperationMessageCollection extends
ServiceDescriptionBaseCollection
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
このクラスのインスタンスは、親 Operation の Messages プロパティから返されます。そのため、ここで持つことができるメンバは、 OperationInput と OperationOutput の 2 つだけです。
使用例
Imports System
Imports System.Xml
Imports System.Web.Services
Imports System.Web.Services.Description
Class MyOperationMessageCollectionSample
Shared Sub Main()
Try
Dim myDescription As ServiceDescription = _
ServiceDescription.Read("MathService_input_vb.wsdl")
Dim myPortTypeCollection As PortTypeCollection = _
myDescription.PortTypes
' Get the OperationCollection for the SOAP protocol.
Dim myOperationCollection As OperationCollection = _
myPortTypeCollection(0).Operations
' Get the OperationMessageCollection for the Add operation.
Dim myOperationMessageCollection As OperationMessageCollection = _
myOperationCollection(0).Messages
' Display the Flow, Input, and Output properties.
DisplayFlowInputOutput(myOperationMessageCollection, "Start")
' 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)
DisplayFlowInputOutput(myOperationMessageCollection, "Add")
If myOperationMessageCollection.Contains(myOperationMessage) _
= True Then
Dim myIndex As Integer = _
myOperationMessageCollection.IndexOf(myOperationMessage)
Console.WriteLine(" The index of the Add operation " & _
"message in the collection is : " & myIndex.ToString())
End If
myOperationMessageCollection.Remove(myInputOperationMessage)
' Display Flow, Input, and Output after removing.
DisplayFlowInputOutput(myOperationMessageCollection, "Remove")
' Insert the message at index 0 in the collection.
myOperationMessageCollection.Insert(0, myInputOperationMessage)
' Display Flow, Input, and Output after inserting.
DisplayFlowInputOutput(myOperationMessageCollection, "Insert")
myDescription.Write("MathService_new_vb.wsdl")
Catch e As Exception
Console.WriteLine("Exception caught!!!")
Console.WriteLine("Source : " & e.Source.ToString())
Console.WriteLine("Message : " & e.Message.ToString())
End Try
End Sub 'Main
' Displays the properties of the OperationMessageCollection.
Public Shared Sub DisplayFlowInputOutput(myOperationMessageCollection As _
OperationMessageCollection, myOperation As String)
Console.WriteLine("After " & myOperation.ToString() & ":")
Console.WriteLine("Flow : " & _
myOperationMessageCollection.Flow.ToString())
Console.WriteLine("The first occurrence of operation Input " & _
"in the collection {0}" , myOperationMessageCollection.Input)
Console.WriteLine("The first occurrence of operation Output " & _
"in the collection " & myOperationMessageCollection.Output.ToString())
Console.WriteLine()
End Sub 'DisplayFlowInputOutput
End Class 'MyOperationMessageCollectionSample
[C#]
using System;
using System.Xml;
using System.Web.Services;
using System.Web.Services.Description;
class MyOperationMessageCollectionSample
{
static void Main()
{
try
{
ServiceDescription myDescription =
ServiceDescription.Read("MathService_input_cs.wsdl");
PortTypeCollection myPortTypeCollection =
myDescription.PortTypes;
// Get the OperationCollection for the SOAP protocol.
OperationCollection myOperationCollection =
myPortTypeCollection[0].Operations;
// Get the OperationMessageCollection for the Add operation.
OperationMessageCollection myOperationMessageCollection =
myOperationCollection[0].Messages;
// Display the Flow, Input, and Output properties.
DisplayFlowInputOutput(myOperationMessageCollection, "Start");
// 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);
DisplayFlowInputOutput(myOperationMessageCollection, "Add");
if(myOperationMessageCollection.Contains(myOperationMessage)
== true )
{
int myIndex =
myOperationMessageCollection.IndexOf(myOperationMessage);
Console.WriteLine(" The index of the Add operation " +
"message in the collection is : " + myIndex);
}
myOperationMessageCollection.Remove(myInputOperationMessage);
// Display Flow, Input, and Output after removing.
DisplayFlowInputOutput(myOperationMessageCollection, "Remove");
// Insert the message at index 0 in the collection.
myOperationMessageCollection.Insert(0, myInputOperationMessage);
// Display Flow, Input, and Output after inserting.
DisplayFlowInputOutput(myOperationMessageCollection, "Insert");
myDescription.Write("MathService_new_cs.wsdl");
}
catch(Exception e)
{
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
}
// Displays the properties of the OperationMessageCollection.
public static void DisplayFlowInputOutput( OperationMessageCollection
myOperationMessageCollection, string myOperation)
{
Console.WriteLine("After " + myOperation + ":");
Console.WriteLine("Flow : " + myOperationMessageCollection.Flow);
Console.WriteLine("The first occurrence of operation Input " +
"in the collection " + myOperationMessageCollection.Input);
Console.WriteLine("The first occurrence of operation Output " +
"in the collection " + myOperationMessageCollection.Output);
Console.WriteLine();
}
}
[C++]
#using <mscorlib.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Xml;
using namespace System::Web::Services;
using namespace System::Web::Services::Description;
// Displays the properties of the OperationMessageCollection.
void DisplayFlowInputOutput( OperationMessageCollection* myOperationMessageCollection, String* myOperation)
{
Console::WriteLine(S"After {0}:", myOperation);
Console::WriteLine(S"Flow : {0}", __box(myOperationMessageCollection->Flow));
Console::WriteLine(S"The first occurrence of operation Input in the collection {0}", myOperationMessageCollection->Input );
Console::WriteLine(S"The first occurrence of operation Output in the collection {0}", myOperationMessageCollection->Output );
Console::WriteLine();
}
int main()
{
try
{
ServiceDescription* myDescription =
ServiceDescription::Read(S"MathService_input_cs.wsdl");
PortTypeCollection* myPortTypeCollection =
myDescription->PortTypes;
// Get the OperationCollection for the SOAP protocol.
OperationCollection* myOperationCollection =
myPortTypeCollection->Item[0]->Operations;
// Get the OperationMessageCollection for the Add operation.
OperationMessageCollection* myOperationMessageCollection =
myOperationCollection->Item[0]->Messages;
// Display the Flow, Input, and Output properties.
DisplayFlowInputOutput(myOperationMessageCollection, S"Start");
// 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);
DisplayFlowInputOutput(myOperationMessageCollection, S"Add");
if(myOperationMessageCollection->Contains(myOperationMessage)
== true )
{
int myIndex =
myOperationMessageCollection->IndexOf(myOperationMessage);
Console::WriteLine(S" The index of the Add operation message in the collection is : {0}", __box(myIndex));
}
myOperationMessageCollection->Remove(myInputOperationMessage);
// Display Flow, Input, and Output after removing.
DisplayFlowInputOutput(myOperationMessageCollection, S"Remove");
// Insert the message at index 0 in the collection.
myOperationMessageCollection->Insert(0, myInputOperationMessage);
// Display Flow, Input, and Output after inserting.
DisplayFlowInputOutput(myOperationMessageCollection, S"Insert");
myDescription->Write(S"MathService_new_cs.wsdl");
}
catch(Exception* e)
{
Console::WriteLine(S"Exception caught!!!");
Console::WriteLine(S"Source : {0}", e->Source);
Console::WriteLine(S"Message : {0}", e->Message);
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Web.Services.Description
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Web.Services (System.Web.Services.dll 内)
参照
OperationMessageCollection メンバ | System.Web.Services.Description 名前空間