aspose file tools*
The moose likes Web Services and the fly likes Ray Lai : Difference between Dynamic Proxies and Dynamic Invocation Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Ray Lai : Difference between Dynamic Proxies and Dynamic Invocation Interface" Watch "Ray Lai : Difference between Dynamic Proxies and Dynamic Invocation Interface" New topic
Author

Ray Lai : Difference between Dynamic Proxies and Dynamic Invocation Interface

Xie Ruchang
Ranch Hand

Joined: Dec 25, 2003
Posts: 160
Hi Ray,
I understand beside Generated Stubs, the other two ways of programming JAX-RPC clients are Dynamic Proxies and Dynamic Invocation Interface. Beside the programming differences which most books cover, what are the factors that influence the choice of these two methods of implementing web services clients? Could you briefly state the pros and cons of these two methods? Thank you.
Best Regards
Frankie
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The dynamic proxy method requires application-specific interfaces (see "dynamicproxy.HelloIF" in http://java.sun.com/webservices/docs/1.3/tutorial/doc/JAXRPC5.html#wp79973 for example) while DII does not pose such requirements and is "completely" dynamic.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ray Lai
author
Greenhorn

Joined: Feb 23, 2004
Posts: 17
Originally posted by Frankie Cha:
I understand beside Generated Stubs, the other two ways of programming JAX-RPC clients are Dynamic Proxies and Dynamic Invocation Interface. Beside the programming differences which most books cover, what are the factors that influence the choice of these two methods of implementing web services clients? Could you briefly state the pros and cons of these two methods? Thank you.

With dynamic proxies, developers can simply refer to a WSDL. This simply denotes "static look-up". You do need to generate the service end-point interface (*IF) file though using wscompile or similar utility. This scenario is ideal if you are managing a set of WSDLs that do not require frequent changes.
With dynamic invocation interface (DII), developers can perform service discovery using UDDI or JAXR on the fly. They will create an instance of an RPC call, and instantiate with relevant service end-point information. This scenario is ideal for services that have frequent updates, or that involve frequent addition/changes in the service contents, or in the number of service providers/trading partners.
From a programming construct point of view, you've probably noted that
DII is slightly more complex, as you need to be more specific about what properties/attributes for the RPC call (e.g. call.setProperty(xxx)). But it gives you more flexibility in managing changes (e.g. changes in WSDL, changes in service versioning) that cannot be easily managed by dynamic proxies.
To summarize, dynamic proxies are simpler in program design (e.g. faster to code or debug), more suitable for static WSDLs, and thus less service lookup overhead. DII is more agile for managing web services changes (e.g. changes in WSDL content, changes in service versioning), but it requires dynamic UDDI or ebXML service lookup (and thus have overhead). Choosing which method will be a matter of design strategies, and a case of your web services changes requirement. For example, your online store has many merchants joining or exiting. The WSDLs are so volatile and service versioning becomes an issue. It won't be sensible to use the same WSDL all the time, as the merchant may simply add a new parameter next month. Thus, a DII client is more appropriate.
On the other hand, many early web services deployment use static WSDLs that are exchanged between trading partners. They don't prefer dynamic lookup due to (1) lookup overhead, which may cost 0.2-2 seconds/call, and (2) they don't like building a UDDI infrastructure, which may be exposed to potential security risks (e.g. Denial of Attack).
My book J2EE platform web services ch 4 p. 207 (section 4.8.12-13) discusses some performance information about lookup overhead. To mitigate the service lookup overhead, you may also consider using a SOAP cache (pp. 172-178, section 4.8.1), which can be a client-side or a server-side caching.


Free chapter summary/binaries of J2EE Platform Web Services can be found at <a href="http://authors.phptr.com/lai/." target="_blank" rel="nofollow">http://authors.phptr.com/lai/.</a><br />Get your copy from <a href="http://www.amazon.com." target="_blank" rel="nofollow">www.amazon.com.</a>
Xie Ruchang
Ranch Hand

Joined: Dec 25, 2003
Posts: 160
Hi Ray,
Thank you very much for the clear and concise explanation!
Best Regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

With dynamic proxies, developers can simply refer to a WSDL. This simply denotes "static look-up". You do need to generate the service end-point interface (*IF) file though using wscompile or similar utility. This scenario is ideal if you are managing a set of WSDLs that do not require frequent changes.

I dont understand the difference between dynamic proxy and generated stubs. How is dynamic proxy advantageous? How does generating proxies dynamically help?
Thanks


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

The WSDLs are so volatile and service versioning becomes an issue. It won't be sensible to use the same WSDL all the time, as the merchant may simply add a new parameter next month.

How will my program know that the 3rd parameter has been added? The program has to be modified to accomodate 3rd parameter, right? :roll:
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Pradeep Bhat:
How will my program know that the 3rd parameter has been added? The program has to be modified to accomodate 3rd parameter, right? :roll:
Yes (unless the client is built to look for parameter values using reflection on a given "request object", which is unlikely in my opinion).
Madhu
Greenhorn

Joined: Dec 11, 2000
Posts: 16
Hi Ray Lai,
I have a question on Dynamic Invocation Interface..I presume the DII can be used without a WSDL on the client side..But if I have to pass a complexType to a Web Service invocation, how would I create the java representation of that complexType?? If i have to refer to WSDL for this, then how can the DII client be loosely-coupled with the WSDL?If there is any change to the wsdl, then my DII client code has to change..Am I correct?
 
wood burning stoves
 
subject: Ray Lai : Difference between Dynamic Proxies and Dynamic Invocation Interface