This post isn’t going to deal with security directly, but rather with two command line tools that come with the .NET framework. The tools, WSDL.exe and XSD.exe, are used to easily create .NET wrapper classes to deal with web services and XML files, respectively. Both of these command line tools are installed alongside the .NET framework (on my machine, they’re located in C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin, although if you start the Visual Studio command prompt, they should be accessible via PATH entries anyway).
The WSDL tool can quickly create a .NET class that can invoke remote web services given a WSDL service definition. A quick example of how to use the tool would be to open a command prompt and type:
wsdl /namespace:MyProgram.Services /username:user /password:password /out:MyWebService.cs http://webserver/services/MyWebService?wsdl
This will generate the C# class MyProgram.Services.MyWebService.cs in the current folder, with the appropriate objects defined to call the web service defined by that WSDL file. All you have to do is configure a credential (if needed), and you can use the web service through the object.
The XSD tool can be used to create an XSD file and a .NET class based on any XML file, including one you made up yourself with no related schema definition. The XML file could be as simple as:
<MyFolders> <Folder>c:\folder1</Folder> <Folder>c:\folder2</Folder> </MyFolders>
Using the XSD tool, you can generate an XSD file to accompany this XML by opening a command prompt and running:
This will create the MyFolders.xsd schema definition file. Once we have that, we can generate a .NET wrapper class using the same tool:
xsd /namespace MyProgram.Xml /classes /language:CS MyFolders.xsd
This will create the MyProgram.Xml.MyFolders class in the file MyFolders.cs, which you can then use with the System.Xml.Serialization.XmlSerializer class to easily create objects from XML files and vice versa.
Each Thursday, Security Musings features a security-related technology or tool. Featured items do not imply a recommendation by Gemini Security Solutions. For more information about how Gemini Security Solutions can help you solve your security issues, contact us!