WebMessageEncodingBindingElement 類別

定義

啟用在用於 Windows Communication Foundation (WCF) 繫結時,要讀取與寫入的純文字 XML、JavaScript Object Notation (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 sealed class WebMessageEncodingBindingElement : System.ServiceModel.Channels.MessageEncodingBindingElement, System.ServiceModel.Description.IWsdlExportExtension
type WebMessageEncodingBindingElement = class
    inherit MessageEncodingBindingElement
    interface IWsdlExportExtension
Public NotInheritable Class WebMessageEncodingBindingElement
Inherits MessageEncodingBindingElement
Implements IWsdlExportExtension
繼承
WebMessageEncodingBindingElement
實作

備註

編碼是將訊息轉換成位元組序列的處理序,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.

在不使用由 WebHttpBinding 所使用之 SOAP 傳訊的案例中,會使用這個繫結項目及其複合編碼器來控制其編碼方式。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. 這些案例包括 "Plain Old XML" (POX)、代表性狀態傳輸 (Representational State Transfer,REST)、Really Simple Syndication (RSS) 和 Atom 新聞訂閱,以及 Asynchronous 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 一定會傳回 NoneThe 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 和 Textual 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. MaxReadPoolSizeMaxWritePoolSize 等屬性也可以用於設定要分別配置之讀取器和寫入器的最大數目。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.

CanBuildChannelFactory<TChannel>(BindingContext)

傳回值,指出繫結項目是否可以建置 (Build) 特定通道類型的通道處理站。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.

Clone()

新建一個從目前 WebMessageEncodingBindingElement 物件初始化的這類物件。Creates a new WebMessageEncodingBindingElement object initialized from the current one.

CreateMessageEncoderFactory()

建立訊息編碼器處理站,此處理站會產生可以寫入 JavaScript Object Notation (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)

如果存在,則從通道堆疊中的適當層級傳回所要求型別的物件,如果不存在,則為 nullReturns the object of the type requested, if present, from the appropriate layer in the channel stack, or null if it is not present.

GetType()

取得目前執行個體的 TypeGets 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)

明確介面實作

IWmiInstanceProvider.FillInstance(IWmiInstance)
IWmiInstanceProvider.GetInstanceType()
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.

適用於