Tuesday, January 11, 2011

Client Proxies

There are actually three different ways to invoke a Web service:

* static binding
* dynamic binding
* dynamic invocation

With static binding you compile and bind your client proxy at development time. This binding is tightly bound to one and only one service implementation. It provides the fastest performance of the three options, but gives you the least flexibility.

With dynamic binding the only thing that you compile at development time is the interface to a service type (i.e., the WSDL definition). At runtime your client can bind to any service implementation that supports that . It generates a dynamic proxy from the service's WSDL at runtime and casts it to the interface. From a developer's point of view, this approach is as easy to use as a static proxy. There is a slight performance hit, though. You need to retrieve the WSDL and do some runtime compilation of the WSDL, so the initial connection takes a bit longer (a few hundred milliseconds), but once the binding is complete, performance is equivalent. In exchange you win a lot of flexibility. Using this technique, your application can connect to any number of different service implementations without modification. It can automatically handle changes to the underlying protocols. It doesn't automatically handle changes to the service signature, though. For that you need dynamic invocation.

With dynamic invocation, you don't compile anything at development time. Instead you do everything at runtime. The application retrieves and interprets the WSDL it at runtime and dynamically constructs calls. It gives you the most flexibility, but also requires a much more sophisticated client. Obviously, there's a bigger hit in terms of performance, which occurs on each invocation.

No comments:

Post a Comment