Part 10 Message Contract in WCF HD

29.11.2013
Link for code samples used in the demo http://csharp-video-tutorials.blogspot.com/2013/11/part-10-message-contract-in-wcf_28.html Link for all dot net and sql server video tutorial playlists http://www.youtube.com/user/kudvenkat/playlists With Data Contracts we have very limited control over the SOAP XML messages that are generated. Use Message Contracts, if you want to have full control over the generated XML SOAP messages. Few examples of when Message Contracts can be handy 1. Include some custom data in the SOAP header. In general SOAP headers are used to pass user credentials, license keys, session keys etc. 2. Change the name of the wrapper element in the SOAP message or to remove it altogether. In this demo, we will discuss how to use MessageContracts 1. To include LicenseKey in the SOAP Header 2. Change the Name of the wrapper element in the SOAP Body Decorate a class with MessageContract attribute, and then use that class as an operation contract parameter or return type. MessageContract attribute has the following parameters. 1. IsWrapped 2. WrapperName 3. WrapperNamespace 4. ProtectionLevel MessageHeader attribute is applied on a property of the class that you want to include in the SOAP header. MessageHeader attribute has the following parameters. 1. Name 2. Namespace 3. ProtectionLevel 4. Actor 5. MustUnderstand 6. Relay MessageBodyMember attribute is applied on a property of the class that you want to include in the SOAP body section. MessageBodyMember attribute has the following parameters. 1. Name 2. Namespace 3. Order 4. ProtectionLevel In general, use MessageContract only if there is a reason to tweak the structure of the soap XML message.

Похожие видео

Показать еще