Export (0) Print
Expand All

MessageEncoder.ReadMessage Method (ArraySegment<Byte>, BufferManager, String)

When overridden in a derived class, reads a message from a specified stream.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public abstract Message ReadMessage(
	ArraySegment<byte> buffer,
	BufferManager bufferManager,
	string contentType
)

Parameters

buffer
Type: System.ArraySegment<Byte>

A ArraySegment<T> of type Byte that provides the buffer from which the message is deserialized.

bufferManager
Type: System.ServiceModel.Channels.BufferManager

The BufferManager that manages the buffer from which the message is deserialized.

contentType
Type: System.String

The Multipurpose Internet Mail Extensions (MIME) message-level content-type.

Return Value

Type: System.ServiceModel.Channels.Message
The Message that is read from the stream specified.

The following code example shows how to implement the ReadMessage(ArraySegment<Byte>, BufferManager, String) method.

public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType)
{   
    byte[] msgContents = new byte[buffer.Count];
    Array.Copy(buffer.Array, buffer.Offset, msgContents, 0, msgContents.Length);
    bufferManager.ReturnBuffer(buffer.Array);

    MemoryStream stream = new MemoryStream(msgContents);
    return ReadMessage(stream, int.MaxValue);
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft