MessageContractAttribute Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Defines a strongly typed class that corresponds to a SOAP message.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
The MessageContractAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | MessageContractAttribute | Initializes a new instance of the MessageContractAttribute class. |
| Name | Description | |
|---|---|---|
![]() | IsWrapped | Gets or sets a value that specifies whether the message body has a wrapper element. |
![]() | WrapperName | Gets or sets the name of the wrapper element of the message body. |
![]() | WrapperNamespace | Gets or sets the namespace of the message body wrapper element. |
| Name | Description | |
|---|---|---|
![]() | Equals | Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
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.
Note: |
|---|
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.
Capabilities
If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.
ID_CAP_NETWORKING | Windows Phone 8, Windows Phone OS 7.1 |
For more info, see App capabilities and hardware requirements for Windows Phone 8.
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 MessageBodyMemberAttribute (to specify the bodies of both the request and response message). The code example contains an example of each message when sent.



Note: