Message Class
TOC
Collapse the table of content
Expand the table of content

Message Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Represents the unit of communication between endpoints in a distributed environment.

System::Object
  System.ServiceModel.Channels::Message

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

No code example is currently available or this language may not be supported.

The Message type exposes the following members.

  NameDescription
Protected methodMessageInitializes a new instance of the Message class.
Top

  NameDescription
Public propertyHeadersWhen overridden in a derived class, gets the headers of the message.
Protected propertyIsDisposedReturns a value that indicates whether the Message is disposed.
Public propertyIsEmptyReturns a value that indicates whether the Message is empty.
Public propertyIsFaultGets a value that indicates whether this message generates any SOAP faults.
Public propertyPropertiesWhen overridden in a derived class, gets a set of processing-level annotations to the message.
Public propertyStateGets the current state of this Message.
Public propertyVersionWhen overridden in a derived class, gets the SOAP and WS-Addressing versions of the message.
Top

  NameDescription
Public methodCloseCloses the Message and releases any resources.
Public methodStatic memberCreateMessage(MessageVersion, String)Creates a message that contains a version and an action.
Public methodStatic memberCreateMessage(MessageVersion, String, Object)Creates a message with the specified version, action and body.
Public methodStatic memberCreateMessage(MessageVersion, String, BodyWriter)Creates a message with a body that consists of an array of bytes.
Public methodStatic memberCreateMessage(MessageVersion, String, XmlDictionaryReader)Creates a message with the specified version, action and body.
Public methodStatic memberCreateMessage(MessageVersion, String, XmlReader)Creates a message using the specified reader, action and version.
Public methodStatic memberCreateMessage(MessageVersion, String, Object, XmlObjectSerializer)Creates a message using the specified version, action, message body and serializer.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetBody<T>()Retrieves the body of this Message instance.
Public methodGetBody<T>(XmlObjectSerializer)Retrieves the body of this Message using the specified serializer.
Public methodGetBodyAttributeRetrieves the attributes of the message body.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetReaderAtBodyContentsGets the XML dictionary reader that accesses the body content of this message.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnBodyToStringCalled when the message body is converted to a string.
Protected methodOnCloseCalled when the message is closing.
Protected methodOnGetBodyAttributeCalled when the attributes of the message body is retrieved.
Protected methodOnGetReaderAtBodyContentsCalled when an XML dictionary reader that can access the body content of this message can be retrieved.
Protected methodOnWriteBodyContentsCalled when the message body is written to an XML file.
Protected methodOnWriteMessageCalled when the entire message is written to an XML file.
Protected methodOnWriteStartBodyCalled when the start body is written to an XML file.
Protected methodOnWriteStartEnvelopeCalled when the start envelope is written to an XML file.
Protected methodOnWriteStartHeadersCalled when the start header is written to an XML file.
Public methodToStringReturns a string that represents the current Message. (Overrides Object::ToString().)
Public methodWriteBody(XmlDictionaryWriter)Writes the body element using the specified XmlDictionaryWriter.
Public methodWriteBody(XmlWriter)Serializes the message body using the specified XmlWriter.
Public methodWriteBodyContentsSerializes the body content using the specified XmlDictionaryWriter.
Public methodWriteMessage(XmlDictionaryWriter)Serializes the entire message using the specified XmlDictionaryWriter.
Public methodWriteMessage(XmlWriter)Serializes the entire message using the specified XmlWriter.
Public methodWriteStartBody(XmlDictionaryWriter)Serializes the start body using the specified XmlDictionaryWriter.
Public methodWriteStartBody(XmlWriter)Serializes the start body using the specified XmlDictionaryWriter.
Public methodWriteStartEnvelopeSerializes the start envelope using the specified XmlDictionaryWriter.
Top

  NameDescription
Explicit interface implemetationPrivate methodIDisposable::DisposeCloses all the resources used by this message. This method cannot be inherited.
Top

The Message class provides a means of communicating arbitrary information between a sender and a receiver on a network. It can be used to relay information, suggest or demand a course of action, or request data.

The structure of a Message object represents a SOAP envelope. It consists of two distinct parts: the message's body and an optional collection of headers, represented by the Headers class. The message content is application-defined data sent from a sender to a receiver. The message headers enable system and application extensibility to meet the changing requirements, because you can define code to manipulate and respond to specific headers. You can also define your own headers. Message headers are serialized or deserialized along with the contents of the message.

Messages are received and sent in particular formats. Support is provided for one format: the standard text-based XML format. The Message object can be used to represent the SOAP 1.1 envelope. Note that an instance of Message is fixed upon creation and is bound to a specific SOAP version. The Version property represents the SOAP version of the message.

A Message object can be serialized to an external store by using the WriteMessage method. Properties of the message can also be serialized, but they have to be individually identified and serialized separately. Deserializing a message to create an in-memory Message object can be done using CreateMessage. Properties must also be deserialized individually and manually added to the property collection for the specific Message instance.

The size of a Message object is fixed to the size of data it is transmitting. Every body is modeled as an instance of XmlReader, with no predefined limit on the size of the stream that the XmlReader instance is wrapping. However, specific channel providers can have a limit on the size of messages that they process.

A Message can be annotated with useful information generated by an entity that has examined and processed the message. This functionality is provided by the Headers and Properties properties. The Headers collection represents the set of SOAP headers on the message.

The Properties property represents the set of processing-level annotations on the message. Because information in headers is transmitted on the wire, an entity that examines a header must support the underlying version(s) of the protocols used by the header. However, properties provide a more version-independent way of annotating a message.

To create a Message instance, use one of the CreateMessage methods.

It is recommended that an accessor of a message always call Close when the accessor is finished accessing the contents of the message. This action frees finite system resources (for example, sockets, and named pipes) that are tied to the lifetime of the message.

Notes to Inheritors

When you inherit from Message, you must override the following members: Headers, and Version.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2017 Microsoft