Operation 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供 XML Web Service 所支援的動作的抽象定義。 此類別無法獲得繼承。
public ref class Operation sealed : System::Web::Services::Description::DocumentableItem
public ref class Operation sealed : System::Web::Services::Description::NamedItem
public sealed class Operation : System.Web.Services.Description.DocumentableItem
[System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")]
public sealed class Operation : System.Web.Services.Description.NamedItem
type Operation = class
inherit DocumentableItem
[<System.Web.Services.Configuration.XmlFormatExtensionPoint("Extensions")>]
type Operation = class
inherit NamedItem
Public NotInheritable Class Operation
Inherits DocumentableItem
Public NotInheritable Class Operation
Inherits NamedItem
- 繼承
- 繼承
- 屬性
範例
下列範例示範 類別的 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 會對應至元素所 portType
括住的 Web 服務描述語言 (WSDL) operation
元素。 如需 WSDL 的詳細資訊,請參閱 WSDL 規格。
建構函式
Operation() |
初始化 Operation 類別的新執行個體。 |
屬性
Documentation |
取得或設定 DocumentableItem 的執行個體的文字文件。 (繼承來源 DocumentableItem) |
DocumentationElement |
取得或設定 DocumentableItem 的文件項目。 (繼承來源 DocumentableItem) |
ExtensibleAttributes |
取得或設定型別 XmlAttribute 的陣列,表示符合 Web 服務互通性 (WS-I) Basic Profile 1.1 的 WSDL 屬性擴充。 (繼承來源 DocumentableItem) |
Extensions |
取得與這個 ServiceDescriptionFormatExtensionCollection 關聯的 Operation。 |
Extensions |
取得與這個 ServiceDescriptionFormatExtensionCollection 關聯的 DocumentableItem。 (繼承來源 DocumentableItem) |
Faults |
取得由目前 Operation 定義的錯誤或錯誤訊息的集合。 |
Messages | |
Name |
取得或設定 Operation 的名稱。 |
Name |
取得或設定項目的名稱。 (繼承來源 NamedItem) |
Namespaces |
取得或設定命名空間前置詞和命名空間的字典,用於在建構 ServiceDescription 物件時保留命名空間前置詞和命名空間。 (繼承來源 DocumentableItem) |
ParameterOrder |
取得或設定包含於 ParameterOrderString 中的元素陣列。 |
ParameterOrderString |
取得或設定選擇性遠端程序呼叫 (Remote Procedure Call,RPC) 簽章,它會為要求 - 回應或請求 - 回應作業排序規格。 |
PortType |
方法
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
IsBoundBy(OperationBinding) |
傳回值,指出指定的 OperationBinding 是否符合 Operation。 |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |