Export (0) Print
Expand All

MessageContractAttribute Class

Defines a strongly typed class that corresponds to a SOAP message.

System.Object
  System.Attribute
    System.ServiceModel.MessageContractAttribute

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

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct, AllowMultiple := False)> _
Public NotInheritable Class MessageContractAttribute _
	Inherits Attribute

The MessageContractAttribute type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneMessageContractAttributeInitializes a new instance of the MessageContractAttribute class.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneIsWrappedGets or sets a value that specifies whether the message body has a wrapper element.
Public propertySupported by Silverlight for Windows PhoneWrapperNameGets or sets the name of the wrapper element of the message body.
Public propertySupported by Silverlight for Windows PhoneWrapperNamespaceGets or sets the namespace of the message body wrapper element.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneEqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Use the MessageContractAttribute attribute to specify the structure of the SOAP envelope for a particular message. Your service can then use the message as a parameter or return type in service operations.

To implement a message contract for a type, annotate it with MessageContractAttribute and annotate one or more of the class's fields or properties with MessageBodyMemberAttribute, MessageHeaderAttribute, or MessageHeaderArrayAttribute.

NoteNote:

System.ServiceModel.MessageParameterAttribute is not a message contract attribute and cannot be used in conjunction with MessageContractAttribute.

Use the Action and ReplyAction properties to specify the value of the <Action> element in the SOAP message.

  • Use the IsWrapped property to indicate whether the message body has a wrapper element.

  • If the message body has a wrapper element, use the WrapperName property to specify the name of the wrapping element.

  • Use the WrapperNamespace property to specify the namespace of the wrapping element.

The following code example shows the use of the MessageContractAttribute to control the SOAP envelope structure for both the request message and the response message, and the use of both the MessageHeaderAttribute (to create a SOAP header for the response message) and the MessageBodyMemberAttribute (to specify the bodies of both the request and response message). The code example contains an example of each message when sent.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

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

Community Additions

ADD
Show:
© 2014 Microsoft