OperationFormatStyle 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 SOAP 样式,该样式确定如何设置服务的 WSDL 元数据格式。
public enum class OperationFormatStyle
C#
public enum OperationFormatStyle
type OperationFormatStyle =
Public Enum OperationFormatStyle
- 继承
名称 | 值 | 说明 |
---|---|---|
Document | 0 | 导致 WSDL 表示形式包含一个表示与操作交换的文档的元素。 |
Rpc | 1 | 使消息的 WSDL 表示形式针对某个操作进行交换,并如同远程过程调用那样包含参数。 |
下面的代码演示如何使用此枚举。
C#
[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
默认情况下,邮件正文的格式设置为“样式”设置为“文档”。 样式 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 设置此值。
产品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
UWP | 10.0 |