Compartilhar via


<webMessageEncoding>

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.

Schema Hierarchy

<system.serviceModel>
  <bindings>
    <customBinding>
      <binding>
        <webMessageEncoding>

Syntax

<webMessageEncoding 
      maxReadPoolSize="Integer"
   maxWritePoolSize="Integer"
      
writeEncoding=”UnicodeFffeTextEncoding/Utf16TextEncoding/Utf8TextEncoding" />

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

maxReadPoolSize

The amount of messages that can be read simultaneously without allocating new readers. Larger pool sizes make the system more tolerant to activity spikes at the cost of a larger working set. The default is 64 readers for each of the inner encoders (text, JSON, and "raw").

Increasing this number increases memory consumption, but prepares the encoder to deal with sudden bursts of incoming messages because it is able to use readers from the pool that are already created instead of creating new ones.

maxWritePoolSize

The amount of messages that can be sent simultaneously without allocating new writers. Larger pool sizes make the system more tolerant to activity spikes at the cost of a larger working set. The default is 16 writers for each of the inner encoders (text, JSON, and "raw").

Increasing this number increases memory consumption, but prepares the encoder to deal with sudden bursts of outgoing messages because it is able to use writers from the pool that are already created instead of creating new ones.

writeEncoding

Specifies the character set encoding to be used for emitting messages on the binding. Valid values are:

  • UnicodeFffeTextEncoding: Unicode Big Endian encoding.

  • Utf16TextEncoding: Unicode encoding.

  • Utf8TextEncoding: 8-bit encoding.

The default is Utf8TextEncoding. This attribute is of type Encoding.

Child Elements

Element Description

<readerQuotas>

Defines the constraints on the complexity of SOAP messages that can be processed by endpoints configured with this binding. This element is of type XmlDictionaryReaderQuotasElement.

Parent Elements

Element Description

<binding>

Defines all binding capabilities of the custom binding.

Remarks

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.

The webMessageEncoding element 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.

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 element. These scenarios include "Plain Old XML" (POX), Representational State Transfer (REST), Really Simple Syndication (RSS) and Atom syndication, and Asynchronous JavaScript and XML (AJAX). The composite message encoder does not support SOAP or WS-Addressing.

The binding element can be configured with a write character encoding by using the writeEncoding attribute. The supplied 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.

maxReadPoolSize and maxWritePoolSize can also be used to set the maximum number of readers and writers to be allocated respectively. By default 64 readers and 16 writers are allocated.

Default complexity constraints are also set using the <readerQuotas> element to protect against a class of denial of service (DOS) attacks that attempt to use message complexity to tie up endpoint processing resources.

Example

<webMessageEncoding 
    maxReadPoolSize="256"
    maxWritePoolSize="128"
    messageVersion="None"
    textEncoding=”utf-8” 
/>

See Also

Reference

<customBinding>
WebMessageEncodingElement
CustomBinding
MessageEncodingBindingElement
WebMessageEncodingBindingElement

Concepts

Message Encoding

Other Resources

Choosing a Message Encoder
Windows Communication Foundation Bindings
Extending Bindings
Custom Bindings


© 2007 Microsoft Corporation. All rights reserved.
Last Published: 2010-01-05