WebMessageEncodingBindingElement 类
定义
允许在 Windows Communication Foundation (WCF) 绑定中使用纯文本 XML、JavaScript 对象表示法 (JSON) 消息编码和“原始”二进制内容时对其进行读写。Enables plain-text XML, JavaScript Object Notation (JSON) message encodings and "raw" binary content to be read and written when used in a Windows Communication Foundation (WCF) binding.
public ref class WebMessageEncodingBindingElement sealed : System::ServiceModel::Channels::MessageEncodingBindingElement, System::ServiceModel::Description::IWsdlExportExtension
public ref class WebMessageEncodingBindingElement sealed : System::ServiceModel::Channels::MessageEncodingBindingElement
public sealed class WebMessageEncodingBindingElement : System.ServiceModel.Channels.MessageEncodingBindingElement, System.ServiceModel.Description.IWsdlExportExtension
public sealed class WebMessageEncodingBindingElement : System.ServiceModel.Channels.MessageEncodingBindingElement
type WebMessageEncodingBindingElement = class
inherit MessageEncodingBindingElement
interface IWsdlExportExtension
type WebMessageEncodingBindingElement = class
inherit MessageEncodingBindingElement
Public NotInheritable Class WebMessageEncodingBindingElement
Inherits MessageEncodingBindingElement
Implements IWsdlExportExtension
Public NotInheritable Class WebMessageEncodingBindingElement
Inherits MessageEncodingBindingElement
- 继承
- 实现
注解
编码是将消息转换为一个字节序列的过程。Encoding is the process of transforming a message into a sequence of bytes. 解码是反向过程。Decoding is the reverse process. 这些过程都需要字符编码规范。These processes require the specification of a character encoding. WebMessageEncodingBindingElement 的工作方式是委托一系列内部编码器对纯文本 XML 与 JSON 编码以及“原始”二进制数据进行处理。The WebMessageEncodingBindingElement works by delegating to a series of inner encoders to handle the plain-text XML and JSON encodings, and "raw" binary data. 委托由复合消息编码器来完成。This delegation is done by a composite message encoder.
在不使用 SOAP 消息(由 WebHttpBinding 使用)的方案中,用该绑定元素及其复合编码器控制编码。This binding element and its composite encoder are used to control the encoding in scenarios that do not use SOAP messaging used by the WebHttpBinding. 这些方案包括“纯旧式 XML”(POX)、具象状态传输 (REST)、真正简单的整合 (RSS) 与 Atom 整合以及异步 JavaScript 和 XML (AJAX)。These scenarios include "Plain Old XML" (POX), Representational State Transfer (REST), Really Simple Syndication (RSS) and Atom syndication, and Asynchronous JavaScript and XML (AJAX). 复合消息编码器不支持 SOAP 或 WS-Addressing,因此,MessageVersion 总是返回 None。The composite message encoder does not support SOAP or WS-Addressing, and so MessageVersion always returns None.
在使用 WebMessageEncodingBindingElement(Encoding) 构造函数进行构造时可以使用编写字符编码配置绑定元素。The binding element can be configured with a write character encoding at construction time using the WebMessageEncodingBindingElement(Encoding) constructor. Encoding 值指定 JSON 与文本 XML 情况的编写行为。The Encoding value specifies the behavior on write for the JSON and Textual XML cases. 在读取时,将理解任何有效的消息编码与文本编码。On read, any valid message encoding and text encoding is understood.
此构造函数对分配给池的读取器和编写器的最大数量设置默认值,这两个默认值在未分配新的读取器和编写器时分别可用于处理传入和传出消息。This constructor sets default values on the maximum number of readers and writers that are allocated to pools and that are respectively available to process incoming and outgoing messages without allocating new readers or writers. 属性 MaxReadPoolSize 与 MaxWritePoolSize 也可以分别用来设置要分配的读取器和编写器最大数目。The properties MaxReadPoolSize and MaxWritePoolSize can also be used to set the maximum number of readers and writers to be allocated respectively. 默认情况下,将分配 64 个读取器和 16 个编写器。By default 64 readers and 16 writers are allocated.
此构造函数还可以通过 XmlDictionaryReaderQuotas 属性设置对与此编码关联的 ReaderQuotas 的默认复杂性约束,以抵御某种类型的拒绝服务 (DOS) 攻击,这些攻击试图利用消息复杂性来占用终结点处理资源。Default complexity constraints are also set by this constructor on the XmlDictionaryReaderQuotas associated with this encoding by the ReaderQuotas property to protect against a class of denial of service (DOS) attacks that attempt to use message complexity to tie up endpoint processing resources.
WebMessageEncodingBindingElement 含有可以创建消息编码器工厂的 CreateMessageEncoderFactory 方法,该消息编码器工厂会根据指定的内容类型按需生成 JSON、XML 或原始消息解码器与编码器。The WebMessageEncodingBindingElement has a CreateMessageEncoderFactory method that creates a message encoder factory that produces JSON, XML or Raw message decoders and encoders as appropriate depending on the content type specified.
WebMessageEncodingBindingElement 还可以提供针对 HTTP 请求流过的通道生成工厂与侦听器的方法。The WebMessageEncodingBindingElement also provides the methods to build the factories and listeners for the channels through which the HTTP requests flow.
复合编码器及其关联的类和配置组件在部分信任中可用,这种使用无需任何特殊权限。The composite encoder and its associated classes and configuration components are usable in partial trust and this use does not require any special permissions.
构造函数
| WebMessageEncodingBindingElement() |
初始化 WebMessageEncodingBindingElement 类的新实例。Initializes a new instance of the WebMessageEncodingBindingElement class. |
| WebMessageEncodingBindingElement(Encoding) |
使用指定的编写字符编码初始化 WebMessageEncodingBindingElement 类的新实例。Initializes a new instance of the WebMessageEncodingBindingElement class with a specified write character encoding. |
属性
| ContentTypeMapper |
获取或设置传入消息内容类型映射到格式的方式。Gets or sets how the content type of an incoming message is mapped to a format. |
| CrossDomainScriptAccessEnabled |
获取或设置一个值,该值确定是否启用跨域脚本访问。Gets or sets a value that determines if cross domain script access is enabled. |
| MaxReadPoolSize |
获取或设置一个值,该值指定无需分配新的读取器便可处理传入消息的最大读取器数,该数值将分配到池中。Gets or sets a value that specifies the maximum number of readers that is allocated to a pool and that is available to process incoming messages without allocating new readers. |
| MaxWritePoolSize |
获取或设置一个值,该值指定无需分配新的编写器便可处理传出消息的最大编写器数,该数值将分配到池中。Gets or sets a value that specifies the maximum number of writers that is allocated to a pool and that is available to process outgoing messages without allocating new writers. |
| MessageVersion |
获取或设置消息版本,该消息版本指示绑定元素不使用 SOAP 或 WS-Addressing。Gets or sets the message version that indicates that the binding element does not use SOAP or WS-Addressing. |
| ReaderQuotas |
获取可由用此绑定配置的终结点处理的 SOAP 消息的复杂性约束。Gets constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding. |
| WriteEncoding |
获取或设置用于编写消息文本的字符编码。Gets or sets the character encoding that is used to write the message text. |
方法
| BuildChannelFactory<TChannel>(BindingContext) |
在客户端上生成通道工厂堆栈,该通道工厂堆栈可为指定上下文创建指定类型的通道。Builds the channel factory stack on the client that creates a specified type of channel for a specified context. |
| BuildChannelListener<TChannel>(BindingContext) |
在客户端生成通道侦听器堆栈,该通道侦听器堆栈接受针对指定上下文的具有指定类型的通道。Builds the channel listener stack on the client that accepts a specified type of channel for a specified context. |
| BuildChannelListener<TChannel>(BindingContext) |
初始化通道侦听器,用于接受绑定上下文中指定类型的通道。Initializes a channel listener to accept channels of a specified type from the binding context. (继承自 BindingElement) |
| CanBuildChannelFactory<TChannel>(BindingContext) |
返回一个值,该值指示绑定元素是否可以为特定类型的通道生成通道工厂。Returns a value that indicates whether the binding element can build a channel factory for a specific type of channel. (继承自 BindingElement) |
| CanBuildChannelListener<TChannel>(BindingContext) |
返回一个值,该值指示当前绑定是否可以为指定的通道类型和上下文生成侦听器。Returns a value that indicates whether the current binding can build a listener for a specified type of channel and context. |
| CanBuildChannelListener<TChannel>(BindingContext) |
返回一个值,该值指示绑定元素是否可以为特定类型的通道生成侦听器。Returns a value that indicates whether the binding element can build a listener for a specific type of channel. (继承自 BindingElement) |
| Clone() |
创建一个从当前对象初始化的新 WebMessageEncodingBindingElement 对象。Creates a new WebMessageEncodingBindingElement object initialized from the current one. |
| CreateMessageEncoderFactory() |
创建可以生成消息编码器的消息编码器工厂,所生成的消息编码器可以编写 JavaScript 对象表示法 (JSON) 与 XML 消息。Creates a message encoder factory that produces message encoders that can write either JavaScript Object Notation (JSON) or XML messages. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetProperty<T>(BindingContext) |
如果存在,从通道堆栈的适当层返回所请求类型的对象,如果不存在,则为 |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
显式接口实现
| IWsdlExportExtension.ExportContract(WsdlExporter, WsdlContractConversionContext) |
从包含在绑定元素中的编码策略中生成 WSDL 协定信息。Generates WSDL contract information from encoding policies contained in the binding element. |
| IWsdlExportExtension.ExportEndpoint(WsdlExporter, WsdlEndpointConversionContext) |
从包含在绑定元素中的编码策略中生成 WSDL 协定信息。Generates WSDL contract information from encoding policies contained in the binding element. |