語言

OperationFormatStyle 列舉

定義

表示SOAP樣式,決定服務的WSDL元數據格式化方式。

public enum class OperationFormatStyle
public enum OperationFormatStyle
type OperationFormatStyle = 
Public Enum OperationFormatStyle
繼承
OperationFormatStyle

欄位

名稱 值 Description
Document 0

使 WSDL 表示包含一個代表交換文件的單一元素。

Rpc 1

會產生 WSDL 表示交換的操作訊息,並包含如同遠端程序呼叫的參數。

範例

以下程式碼說明如何使用此枚舉。

[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples"),
XmlSerializerFormat(Style = OperationFormatStyle.Rpc,
                                 Use = OperationFormatUse.Encoded)]
public interface IUseAndStyleCalculator
{
    [OperationContract]
    double Add(double n1, double n2);
    [OperationContract]
    double Subtract(double n1, double n2);
    [OperationContract]
    double Multiply(double n1, double n2);
    [OperationContract]
    double Divide(double n1, double n2);
}
<ServiceContract(Namespace:="http://Microsoft.ServiceModel.Samples"), _
XmlSerializerFormat(Style:=OperationFormatStyle.Rpc, _
                    Use:=OperationFormatUse.Encoded)> _
Public Interface IUseAndStyleCalculator

    <OperationContract()> _
    Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double

    <OperationContract()> _
    Function Subtract(ByVal n1 As Double, ByVal n2 As Double) As Double

    <OperationContract()> _
    Function Multiply(ByVal n1 As Double, ByVal n2 As Double) As Double

    <OperationContract()> _
    Function Divide(ByVal n1 As Double, ByVal n2 As Double) As Double

End Interface

備註

預設情況下,訊息內容格式為 Style,設定為 Document。 此樣式 RPC 表示 WSDL 對操作訊息交換的表示包含參數,彷彿是遠端程序呼叫。 以下是一個範例。

<wsdl:message name="IUseAndStyleCalculator_Add_InputMessage">  
  <wsdl:part name="n1" type="xsd:double"/>  
  <wsdl:part name="n2" type="xsd:double"/>  
</wsdl:message>  

將樣式設定為 Document 表示 WSDL 表示法包含單一元素,代表在操作中交換的文件,如下列範例所示。

<wsdl:message name="IUseAndStyleCalculator_Add_InputMessage">  
  <wsdl:part name="parameters" element="tns:Add"/>  
</wsdl:message>  

用 來 System.ServiceModel.XmlSerializerFormatAttribute 設定這個值。

適用於