Reusing an Existing COM Object Within a Web Service

This section assumes that the COM object in question requires state or other things that, on the surface, make it a bad candidate for a Web Service. If all you need to do is write some type handling code or edit the WSDL file, you should be reading Chapter 10 right now. For COM objects that require state, you need to look at some ways of separating the COM object itself from the Web Service interface. You have a number of options, and all of them have different pros and cons associated with them.

You can place requests into a queue. This has the advantage of letting you process requests as they arrive and handle the requests fairly quickly. The downside to this is that you cannot send responses straight back to the user. Use this for services that require a large amount of coordination to complete. In this scenario, the Web Service may also need a method to check on the status of the request.

A COM object that uses ADO or some other technology to communicate will not work well with clients that do not understand that technology. Why? Imagine that the COM object does communicate with ADO. How are you going to serialize a recordset and specify that serialization such that a client understands what you are doing? You could use the ADO.NET approach. This serializes the XSD for the returned recordset. Unfortunately, doing this is time consuming and error prone. Instead, add another COM object or .NET project that accesses the original object. You can then add a stateless, easy-to-use Web Service interface on top of the original object. In the world of design patterns, this is called a façade. Visual Basic .NET may be the best way to accomplish this; it allows you to easily declare and use expressive data types with little or no effort on your part.

Keep in mind that many other options exist to reuse your existing code base. COM interop will often be a better solution than exposing a Web Service. Only expose the existing code as a Web Service to allow other platforms, languages, or Internet-based clients to access the code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.172.38