Last post Apr 01, 2013 08:55 AM by kushalrdalal
Mar 31, 2013 01:53 AM|mou_inn|LINK
i am new in WCF. once i was searching code for uploading file to web server by wcf. i found a code which uses message contract for file details. i just do not understand why people use message contract. according to that situation the coder can use data
contract only instead of message contract....so why they used message contract is not clear.
here is the link of source code for file upload by wcf. just have a look and tell me can we use data contract for file information instead of message contract. give some few good situation when one has to use message contract instead of data contract. thanks
these are the link
Apr 01, 2013 08:55 AM|kushalrdalal|LINK
Here is the details for why we use MessageContract -
Please check this thread from where i have copy pasted it below:
WCF data contracts provide a mapping function between .NET CLR types that are defined in code and XML Schemas Definitions defined by the W3C organization (www.w3c.org/) that are used for communication outside
Message contracts describe the structure of SOAP messages sent to and from a service and enable you to inspect and control most of the details in the SOAP header and body. Whereas data contracts enable interoperability through the XML Schema Definition
(XSD) standard, message contracts enable you to interoperate with any system that communicates through SOAP. Using message contracts gives you complete control over the SOAP message sent to and from a service by providing access to the SOAP headers and bodies
directly. This allows use of simple or complex types to define the exact content of the SOAP parts.
The example you have posted use message header to pass information to the client and hence uses message contract. You can use data contract as well just for the purpose of file upload function.