OperationFormatStyle OperationFormatStyle OperationFormatStyle OperationFormatStyle Enum

定义

表示 SOAP 样式,该样式确定如何设置服务的 WSDL 元数据格式。Represents the SOAP style that determines how the WSDL metadata for the service is formatted.

public enum class OperationFormatStyle
public enum OperationFormatStyle
type OperationFormatStyle = 
Public Enum OperationFormatStyle
继承
OperationFormatStyleOperationFormatStyleOperationFormatStyleOperationFormatStyle

字段

Document Document Document Document 0

导致 WSDL 表示形式包含一个表示与操作交换的文档的元素。Causes the WSDL representation to contain a single element that represents the document that is exchanged for the operation.

Rpc Rpc Rpc Rpc 1

使消息的 WSDL 表示形式针对某个操作进行交换,并如同远程过程调用那样包含参数。Causes the WSDL representation of messages exchanged for an operation and contains parameters as if it were a remote procedure call.

示例

下面的代码演示如何使用此枚举。The following code shows how to use this enumeration.

[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

注解

默认情况下,消息正文的格式设置为文档的样式。By default, the message body is formatted with the Style set to Document. 样式 RPC 意味着与操作交换的消息的 WSDL 表示形式包含参数,如同远程过程调用那样。The style RPC means that the WSDL representation of messages exchanged for an operation contains parameters as if it were a remote procedure call. 下面是一个示例。The following is an example.

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

将样式设置为 Document 意味着 WSDL 表示形式包含一个表示与操作交换的文档的元素,如下面的示例所示。Setting the style to Document means that the WSDL representation contains a single element that represents the document that is exchanged for an operation as shown in the following example.

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

使用 System.ServiceModel.XmlSerializerFormatAttribute 设置此值。Use the System.ServiceModel.XmlSerializerFormatAttribute to set this value.

适用于