Is it safe to reuse javax.xml.ws.Service objects

Posted by Noel Ang on Stack Overflow See other posts from Stack Overflow or by Noel Ang
Published on 2010-03-17T21:08:29Z Indexed on 2010/03/17 21:11 UTC
Read the original article Hit count: 351

Filed under:
|
|
|
|

I have JAX-WS style web service client that was auto-generated with the NetBeans IDE.

The generated proxy factory (extends javax.xml.ws.Service) delegates proxy creation to the various Service.getPort methods. The application that I am maintaining instantiates the factory and obtains a proxy each time it calls the targetted service.

Creating the new proxy factory instances repeatedly has been shown to be expensive, given that the WSDL documentation supplied to the factory constructor, an HTTP URI, is re-retrieved for each instantiation.

We had success in improving the performance by caching the WSDL. But this has ugly maintenance and packaging implications for us.

I would like to explore the suitability of caching the proxy factory itself. Is it safe, e.g., can two different client classes, executing on the same JVM and targetting the same web service, safely use the same factory to obtain distinct proxy objects (or a shared, reentrant one)?

I've been unable to find guidance from either the JAX-WS specification nor the javax.xml.ws API documentation. The factory-proxy multiplicity is unclear to me. Having Service.getPort rather than Service.createPort does not inspire confidence.

© Stack Overflow or respective owner

Related posts about java

Related posts about jax-ws