While designing data exchange through the use of web services, one must think of what data is required to travel and how it can be described.
SOAP is an XML based format, so the most natural thing to happen is for us to design a schema for an XML representation of the information and later embed it on a SOAP envelope response.
When implementing a web service using .NET we can rest assured that the framework will provide the WSDL descriptor file automatically. But there’s another task to be done: implement the classes to support the data handling.
The good news is that .NET also has a tool for that matter, called XSD.EXE. It’s a command line utility that takes an XML schema file (XSD) and generates a file with the classes to serialize all the information described on the file.
To view the options available type: xsd.exe /?
To generate classes using C# for a schema called myData.xsd, with the dot.coder.data name space, you could type:
xsd -c -l:c# -n:dot.coder.data myData.xsd
After the source code file is generated you can add it to your Visual Studio Project, for Web Services or other purposes.