Operation 类

定义

提供 XML Web services 所支持的操作的抽象定义。 此类不能被继承。

public ref class Operation sealed : System::Web::Services::Description::NamedItem
public ref class Operation sealed : System::Web::Services::Description::DocumentableItem
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class Operation : System.Web.Services.Description.NamedItem
public sealed class Operation : System.Web.Services.Description.DocumentableItem
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type Operation = class
    inherit NamedItem
type Operation = class
    inherit DocumentableItem
Public NotInheritable Class Operation
Inherits NamedItem
Public NotInheritable Class Operation
Inherits DocumentableItem
继承
继承
属性

示例

以下示例演示 类的典型用法 Operation 。 本示例采用一个 ServiceDescription ,它没有 PortType 支持 HTTP POST 协议的 。 它添加一个 PortType 支持 POST 的实例,并写出新的 WSDL 协定。

#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>

using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;
Operation^ CreateOperation( String^ myOperationName, String^ myInputMesg, String^ myOutputMesg )
{
   
   // Create an Operation.
   Operation^ myOperation = gcnew Operation;
   myOperation->Name = myOperationName;
   OperationMessage^ myInput = dynamic_cast<OperationMessage^>(gcnew OperationInput);
   myInput->Message = gcnew XmlQualifiedName( myInputMesg );
   OperationMessage^ myOutput = dynamic_cast<OperationMessage^>(gcnew OperationOutput);
   myOutput->Message = gcnew XmlQualifiedName( myOutputMesg );
   
   // Add messages to the OperationMessageCollection.
   myOperation->Messages->Add( myInput );
   myOperation->Messages->Add( myOutput );
   Console::WriteLine( "Operation name is: {0}", myOperation->Name );
   
   return myOperation;
}

int main()
{
   ServiceDescription^ myDescription = ServiceDescription::Read( "Operation_5_Input_CS.wsdl" );
   
   // Create a 'PortType' object.
   PortType^ myPortType = gcnew PortType;
   myPortType->Name = "OperationServiceHttpPost";
   Operation^ myOperation = CreateOperation( "AddNumbers", "s0:AddNumbersHttpPostIn", "s0:AddNumbersHttpPostOut" );
   myPortType->Operations->Add( myOperation );
   
   // Get the PortType of the Operation. 
   PortType^ myPort = myOperation->PortType;
   Console::WriteLine( "The port type of the operation is: {0}", myPort->Name );
   
   // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
   myDescription->PortTypes->Add( myPortType );
   
   // Write the 'ServiceDescription' as a WSDL file.
   myDescription->Write( "Operation_5_Output_CS.wsdl" );
   Console::WriteLine( "WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully" );
}
using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

class MyOperationClass
{
   public static void Main()
   {
      ServiceDescription myDescription = ServiceDescription.Read("Operation_5_Input_CS.wsdl");
      // Create a 'PortType' object.
      PortType myPortType = new PortType();
      myPortType.Name = "OperationServiceHttpPost";
      Operation myOperation = CreateOperation
                         ("AddNumbers","s0:AddNumbersHttpPostIn","s0:AddNumbersHttpPostOut");
      myPortType.Operations.Add(myOperation);
      // Get the PortType of the Operation.
      PortType myPort = myOperation.PortType;
      Console.WriteLine(
         "The port type of the operation is: " + myPort.Name);
      // Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
      myDescription.PortTypes.Add(myPortType);

      // Write the 'ServiceDescription' as a WSDL file.
      myDescription.Write("Operation_5_Output_CS.wsdl");
      Console.WriteLine("WSDL file with name 'Operation_5_Output_CS.wsdl' file created Successfully");
   }
   public static Operation CreateOperation(string myOperationName,string myInputMesg,string myOutputMesg)
   {
      // Create an Operation.
      Operation myOperation = new Operation();
      myOperation.Name = myOperationName;
      OperationMessage myInput = (OperationMessage)new OperationInput();
      myInput.Message =  new XmlQualifiedName(myInputMesg);
      OperationMessage myOutput = (OperationMessage)new OperationOutput();
      myOutput.Message = new XmlQualifiedName(myOutputMesg);

      // Add messages to the OperationMessageCollection.
      myOperation.Messages.Add(myInput);
      myOperation.Messages.Add(myOutput);
      Console.WriteLine("Operation name is: " + myOperation.Name);
      return myOperation;
   }
}
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MyOperationClass
   
   Public Shared Sub Main()
      Dim myDescription As ServiceDescription = ServiceDescription.Read("Operation_5_Input_VB.wsdl")
      ' Create a 'PortType' object.
      Dim myPortType As New PortType()
      myPortType.Name = "OperationServiceHttpPost"
      Dim myOperation As Operation = CreateOperation("AddNumbers", "s0:AddNumbersHttpPostIn", _
                                                                     "s0:AddNumbersHttpPostOut")
      myPortType.Operations.Add(myOperation)
      ' Get the PortType of the Operation. 
      Dim myPort As PortType = myOperation.PortType
        Console.WriteLine( _
           "The port type of the operation is: " & myPort.Name)
      ' Add the 'PortType's to 'PortTypeCollection' of 'ServiceDescription'.
      myDescription.PortTypes.Add(myPortType)
      
      ' Write the 'ServiceDescription' as a WSDL file.
      myDescription.Write("Operation_5_Output_VB.wsdl")
      Console.WriteLine("WSDL file with name 'Operation_5_Output_VB.wsdl'" + _ 
                           "file created Successfully")
   End Sub
   
   Public Shared Function CreateOperation(myOperationName As String, myInputMesg As String, _
                                                         myOutputMesg As String) As Operation
      ' Create an Operation.
      Dim myOperation As New Operation()
      myOperation.Name = myOperationName
      Dim myInput As OperationMessage = _
         CType(New OperationInput(), OperationMessage)
      myInput.Message = New XmlQualifiedName(myInputMesg)
      Dim myOutput As OperationMessage = _
         CType(New OperationOutput(), OperationMessage)
      myOutput.Message = New XmlQualifiedName(myOutputMesg)

      ' Add messages to the OperationMessageCollection.
      myOperation.Messages.Add(myInput)
      myOperation.Messages.Add(myOutput)
      Console.WriteLine("Operation name is: " & myOperation.Name)
      Return myOperation
   End Function 'CreateOperation 
End Class

注解

Operation 对应于 Web 服务描述语言 (WSDL) operation 元素括起来的 portType 元素。 有关 WSDL 的更多信息,请参阅 WSDL 规范。

构造函数

Operation()

初始化 Operation 类的新实例。

属性

Documentation

获取或设置 DocumentableItem 的实例的文本文档。

(继承自 DocumentableItem)
DocumentationElement

获取或设置 DocumentableItem 的文档元素。

(继承自 DocumentableItem)
ExtensibleAttributes

获取或设置类型为 XmlAttribute 的数组,该数组表示为符合 Web 服务互操作性 (WS-I) 基本概要 1.1 而进行的 WSDL 特性扩展。

(继承自 DocumentableItem)
Extensions

获取与此 ServiceDescriptionFormatExtensionCollection 关联的 Operation

Extensions

获取与此 ServiceDescriptionFormatExtensionCollection 关联的 DocumentableItem

(继承自 DocumentableItem)
Faults

获取由当前 Operation 定义的错误或错误信息的集合。

Messages

获取由当前 Message 定义的 Operation 类的实例的集合。

Name

获取或设置 Operation 的名称。

Name

获取或设置项的名称。

(继承自 NamedItem)
Namespaces

获取或设置命名空间前缀和命名空间的字典,该字典用于在构造 ServiceDescription 对象时,保留命名空间的前缀和命名空间。

(继承自 DocumentableItem)
ParameterOrder

获取或设置 ParameterOrderString 中包含的元素的数组。

ParameterOrderString

获取或设置可选的远程过程调用 (RPC) 签名,它将请求-响应或恳求-响应操作规范排序。

PortType

获取 PortType 为其成员的 Operation

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
IsBoundBy(OperationBinding)

返回一个值,该值指示指定的 OperationBinding 是否与 Operation 匹配。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅