by Arra Derderian
10. September 2011 18:53
Have you ever had to produce a WCF service or POX webservice that returns valid markup based on a third party schema? Well I have. There is alot of industry standards out there for data transfer and integration. Chances are you may have to support communicating within these means via a webservice. Well as long as you can get your hands on an XSD document for the XML you need to generate Visual Studio makes it easy for you to do this. XSD.exe is a tool that comes with Visual Studio and it allows you to auto generate class files based on your XSD document.
For example, you have a set of data that stored in your database that you need to communicate with an outside party and you both agree to use a common standard of XML for communication. (Maybe you are in mutual fund trading and there is a standard out there for fund transfer, or the other company has an existing schema they would like you to use.) If there is and XSD document provided by the governing body of that protocol or the company you can simply run "xsd.exe file.xm"l from the command line and you got your application layer for you webservice. Simply drop those class files into your solution and make a database call to populate the objects and return it via your webservice call.
I like this method over supporting WSDL for services because it is safer from my point of view. No need to publicly expose any internal information and only the parties with the XSD.exe document know how to communicate. The methods and locations of the service are hidden from the end party as well.