简体   繁体   中英

Using Two different JAX-WS client implementations

I have two internal client libraries. One uses JAX-WS RI (I think its Metro now) and the other Apache CXF . Both of these clients need to be loaded in the same Web App. The reason both cannot use Metro is because one of the clients needs XmlBeans (despite my best attempts at XJB transforming the schema I could not get JAXB to work).

The obvious solution I guess is to port the other client to CXF however what if I create a custom fake Provider that uses ThreadLocal variable that says which real provider to use then have a static method to set the ThreadLocal variable before using the client.

Is that a bad idea?

I ended up creating ThreadLocal based provider which works quite nicely.

You can see the code at this gist .

You can switch from JAXWS and CXF like:

To force a provider

   ThreadLocalProvider.setProvider(ThreadLocalProvider.JAXWS_RI_PROVIDER);

OR

   ThreadLocalProvider.setProvider(ThreadLocalProvider.CXF_PROVIDER);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM