In this post we show you how to make useful the output from svcutil. For example, in the generated code there is a ResourceClient class which has the familiar method Get. This method invokes the WS-Transfer Get operation on the server. The tricky part is the Get method takes a Message class rather than a nice GetRequest or unique identifier. To use this auto-generated client, you must construct the SOAP messages.
Constructing the SOAP message is very doable and simple once you understand the key concept. To create a Message class, you use the factory method Message.CreateMessage(). This factory method requires, among other things, an object and your concrete implementation of XmlObjectSerializer. For the GetRequest, you would need to create a class that stores the content of a get request (e.g. the reference property of the ILM object). You then need to create your own XmlObjectSerializer that knows how to turn your class into the XML we talked about in previous posts. The CreateMessage method takes your object, asks the serializer to produce XML based on your object, and inserts the XML into the Message body. For someone who simply wants to get an object, this is a little bit of work.
For the sake of efficiency we leave building a client as an exercise for the reader.
As an alternative, we are pleased to announce a functional sample client available for download at MSDN Code Gallery. Check it out here:
This sample client is provided “as is” and is not intended for production use. It is a glorified form of documentation that replaces what would have been multiple blog posts. Please use this client to see, for instance, how we use an XmlObjectSerializer to convert our GetRequest class into the Message. Also, please use this client to evaluate the potential scenarios you can solve using the web service interface. We’ve heard a lot of customers ask for batch operations – consider using a web service client to make WS-Transfer calls. Perhaps you want to connect SQL Reporting Services to ILM for auditing and report – consider using a web service client to make WS-Enumeration calls with relevant filters. A lot is possible.
If you choose to use this client in production, please be aware that there is no support from Microsoft for it. You are responsible for testing and supporting the code outright.
Please download the client, open up the visual studio solution file, and start poking around the code.
Enough boring text! In our next topic we’ll discuss SOAP faults you will come across and then dive into useful scenarios. The code for the useful scenarios already exist in the sample client, so please feel free to read ahead.