How to build your custom client
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.
To build your client
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.
Not to build your client
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.
- This is unsupported code that shows how one could build a client. It is not a polished client, nor is it the client the ILM portal uses. We wrote this client using only the specs and knowledge of WCF as if we were a customer or partner.
- This client works for the remaining topics of this blog (11-16) and may work for other topics not yet covered. Your mileage will vary.
- We only tested this client against the ILM “2” RC VPC we released at IT Forum. We have not tested this with a wide range of deployments and scenarios. Your mileage will vary.
- We encourage you to fork and take ownership of this code as we released it under the MS-PL.
- Be prepared to step into the code and debug.
- Please give us feedback! While shipping ILM “2” is our highest priority, we are still interested in your comments.
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.