What are the pros and cons of static invocation of a Web service versus dynamic invocation?
There are actually three different ways to invoke a Web service:
- static binding
- dynamic binding
- dynamic invocation
With dynamic binding the only thing that you compile at development time is the interface to a service type (i.e., the WSDL <portType> definition). At runtime your client can bind to any service implementation that supports that <portType>. It generates a dynamic proxy from the service's WSDL <binding> 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.
Related Q&A from Anne Thomas Manes
Anne Thomas Manes explains the differences between open source clients and open source implementations.continue reading
Anne Thomas Manes discusses the best way to go about creating an enterprise data dictionary and why the systems works well.continue reading
Anne Thomas Manes explains the difference between 'hard' real time and 'live' real time systems.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.