OperationCollection-Klasse
Stellt eine Auflistung von Instanzen der Operation-Klasse dar. Diese Klasse kann nicht geerbt werden.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
Syntax
'Declaration
Public NotInheritable Class OperationCollection
Inherits ServiceDescriptionBaseCollection
'Usage
Dim instance As OperationCollection
public sealed class OperationCollection : ServiceDescriptionBaseCollection
public ref class OperationCollection sealed : public ServiceDescriptionBaseCollection
public final class OperationCollection extends ServiceDescriptionBaseCollection
public final class OperationCollection extends ServiceDescriptionBaseCollection
Hinweise
Die Operation-Klasse entspricht dem WSDL-<operation>-Element (Web Services Description Language), das vom <portType>-Element eingeschlossen wird. Weitere Informationen über WSDL finden Sie in der Spezifikation unter http://www.w3.org/TR/wsdl/.
Beispiel
Das folgende Beispiel veranschaulicht die Verwendung der durch die OperationCollection-Klasse verfügbar gemachten Eigenschaften und Methoden.
Option Strict On
Imports System
Imports System.Web.Services
Imports System.Xml
Imports System.Web.Services.Description
Class MyOperationCollectionSample
Public Shared Sub Main()
Try
' Read the 'MathService_Input_vb.wsdl' file.
Dim myDescription As ServiceDescription = _
ServiceDescription.Read("MathService_Input_vb.wsdl")
Dim myPortTypeCollection As PortTypeCollection = _
myDescription.PortTypes
' Get the 'OperationCollection' for 'SOAP' protocol.
Dim myOperationCollection As OperationCollection = _
myPortTypeCollection(0).Operations
Dim myOperation As New Operation()
myOperation.Name = "Add"
Dim myOperationMessageInput As OperationMessage = _
CType(New OperationInput(), OperationMessage)
myOperationMessageInput.Message = New XmlQualifiedName _
("AddSoapIn", myDescription.TargetNamespace)
Dim myOperationMessageOutput As OperationMessage = _
CType(New OperationOutput(), OperationMessage)
myOperationMessageOutput.Message = New XmlQualifiedName _
("AddSoapOut", myDescription.TargetNamespace)
myOperation.Messages.Add(myOperationMessageInput)
myOperation.Messages.Add(myOperationMessageOutput)
myOperationCollection.Add(myOperation)
If myOperationCollection.Contains(myOperation) = True Then
Console.WriteLine("The index of the added 'myOperation' " + _
"operation is : " + _
myOperationCollection.IndexOf(myOperation).ToString)
End If
myOperationCollection.Remove(myOperation)
' Insert the 'myOpearation' operation at the index '0'.
myOperationCollection.Insert(0, myOperation)
Console.WriteLine("The operation at index '0' is : " + _
myOperationCollection.Item(0).Name)
Dim myOperationArray(myOperationCollection.Count) As Operation
myOperationCollection.CopyTo(myOperationArray, 0)
Console.WriteLine("The operation(s) in the collection are :")
Dim i As Integer
For i = 0 To myOperationCollection.Count - 1
Console.WriteLine(" " + myOperationArray(i).Name)
Next i
myDescription.Write("MathService_New_vb.wsdl")
Catch e As Exception
Console.WriteLine("Exception caught!!!")
Console.WriteLine("Source : " + e.Source)
Console.WriteLine("Message : " + e.Message)
End Try
End Sub
End Class
using System;
using System.Web.Services;
using System.Xml;
using System.Web.Services.Description;
class MyOperationCollectionSample
{
public static void Main()
{
try
{
// Read the 'MathService_Input_cs.wsdl' file.
ServiceDescription myDescription =
ServiceDescription.Read("MathService_Input_cs.wsdl");
PortTypeCollection myPortTypeCollection =myDescription.PortTypes;
// Get the 'OperationCollection' for 'SOAP' protocol.
OperationCollection myOperationCollection =
myPortTypeCollection[0].Operations;
Operation myOperation = new Operation();
myOperation.Name = "Add";
OperationMessage myOperationMessageInput =
(OperationMessage) new OperationInput();
myOperationMessageInput.Message = new XmlQualifiedName
("AddSoapIn",myDescription.TargetNamespace);
OperationMessage myOperationMessageOutput =
(OperationMessage) new OperationOutput();
myOperationMessageOutput.Message = new XmlQualifiedName(
"AddSoapOut",myDescription.TargetNamespace);
myOperation.Messages.Add(myOperationMessageInput);
myOperation.Messages.Add(myOperationMessageOutput);
myOperationCollection.Add(myOperation);
if(myOperationCollection.Contains(myOperation) == true)
{
Console.WriteLine("The index of the added 'myOperation' " +
"operation is : " +
myOperationCollection.IndexOf(myOperation));
}
myOperationCollection.Remove(myOperation);
// Insert the 'myOpearation' operation at the index '0'.
myOperationCollection.Insert(0, myOperation);
Console.WriteLine("The operation at index '0' is : " +
myOperationCollection[0].Name);
Operation[] myOperationArray = new Operation[
myOperationCollection.Count];
myOperationCollection.CopyTo(myOperationArray, 0);
Console.WriteLine("The operation(s) in the collection are :");
for(int i = 0; i < myOperationCollection.Count; i++)
{
Console.WriteLine(" " + myOperationArray[i].Name);
}
myDescription.Write("MathService_New_cs.wsdl");
}
catch(Exception e)
{
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
}
}
#using <System.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Web::Services;
using namespace System::Xml;
using namespace System::Web::Services::Description;
int main()
{
try
{
// Read the 'MathService_Input_cs.wsdl' file.
ServiceDescription^ myDescription = ServiceDescription::Read( "MathService_Input_cs.wsdl" );
PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes;
// Get the 'OperationCollection' for 'SOAP' protocol.
OperationCollection^ myOperationCollection = myPortTypeCollection[ 0 ]->Operations;
Operation^ myOperation = gcnew Operation;
myOperation->Name = "Add";
OperationMessage^ myOperationMessageInput = (OperationMessage^)(gcnew OperationInput);
myOperationMessageInput->Message = gcnew XmlQualifiedName( "AddSoapIn",myDescription->TargetNamespace );
OperationMessage^ myOperationMessageOutput = (OperationMessage^)(gcnew OperationOutput);
myOperationMessageOutput->Message = gcnew XmlQualifiedName( "AddSoapOut",myDescription->TargetNamespace );
myOperation->Messages->Add( myOperationMessageInput );
myOperation->Messages->Add( myOperationMessageOutput );
myOperationCollection->Add( myOperation );
if ( myOperationCollection->Contains( myOperation ) == true )
{
Console::WriteLine( "The index of the added 'myOperation' operation is : {0}", myOperationCollection->IndexOf( myOperation ) );
}
myOperationCollection->Remove( myOperation );
// Insert the 'myOpearation' operation at the index '0'.
myOperationCollection->Insert( 0, myOperation );
Console::WriteLine( "The operation at index '0' is : {0}", myOperationCollection[ 0 ]->Name );
array<Operation^>^myOperationArray = gcnew array<Operation^>(myOperationCollection->Count);
myOperationCollection->CopyTo( myOperationArray, 0 );
Console::WriteLine( "The operation(s) in the collection are :" );
for ( int i = 0; i < myOperationCollection->Count; i++ )
{
Console::WriteLine( " {0}", myOperationArray[ i ]->Name );
}
myDescription->Write( "MathService_New_cs.wsdl" );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception caught!!!" );
Console::WriteLine( "Source : {0}", e->Source );
Console::WriteLine( "Message : {0}", e->Message );
}
}
import System.*;
import System.Web.Services.*;
import System.Xml.*;
import System.Web.Services.Description.*;
class MyOperationCollectionSample
{
public static void main(String[] args)
{
try {
// Read the 'MathService_Input_jsl.wsdl' file.
ServiceDescription myDescription = ServiceDescription.
Read("MathService_Input_jsl.wsdl");
PortTypeCollection myPortTypeCollection = myDescription.
get_PortTypes();
// Get the 'OperationCollection' for 'SOAP' protocol.
OperationCollection myOperationCollection = myPortTypeCollection.
get_Item(0).get_Operations();
Operation myOperation = new Operation();
myOperation.set_Name("Add");
OperationMessage myOperationMessageInput = (OperationMessage)
new OperationInput();
myOperationMessageInput.set_Message(new XmlQualifiedName(
"AddSoapIn", myDescription.get_TargetNamespace()));
OperationMessage myOperationMessageOutput = (OperationMessage)
new OperationOutput();
myOperationMessageOutput.set_Message(new XmlQualifiedName(
"AddSoapOut", myDescription.get_TargetNamespace()));
myOperation.get_Messages().Add(myOperationMessageInput);
myOperation.get_Messages().Add(myOperationMessageOutput);
myOperationCollection.Add(myOperation);
if (myOperationCollection.Contains(myOperation) == true) {
Console.WriteLine("The index of the added 'myOperation' "
+ "operation is : "
+ myOperationCollection.IndexOf(myOperation));
}
myOperationCollection.Remove(myOperation);
// Insert the 'myOpearation' operation at the index '0'.
myOperationCollection.Insert(0, myOperation);
Console.WriteLine("The operation at index '0' is : "
+ myOperationCollection.get_Item(0).get_Name());
Operation myOperationArray[] = new Operation[myOperationCollection.
get_Count()];
myOperationCollection.CopyTo(myOperationArray, 0);
Console.WriteLine("The operation(s) in the collection are :");
for (int i = 0; i < myOperationCollection.get_Count(); i++) {
Console.WriteLine(" " + myOperationArray[i].get_Name());
}
myDescription.Write("MathService_New_jsl.wsdl");
}
catch (System.Exception e) {
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.get_Source());
Console.WriteLine("Message : " + e.get_Message());
}
} //main
} //MyOperationCollectionSample
Vererbungshierarchie
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
System.Web.Services.Description.OperationCollection
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
OperationCollection-Member
System.Web.Services.Description-Namespace