简体   繁体   中英

How can I share classes between client and server?

I've created a jax-ws service endpoint and now I want to write a client. I want to have a shared jar between the client and server for common (JAXB annotated) entity classes and interfaces for the services. Is it possible to force jax-ws to generate (or allow me to write) a client using my existing entites/interfaces?

For those that are wondering why I would want to do this: I want to allow services to be in the same physical server or across the internet, but not make web service calls and just use a different implementation locally.

If you have annotated JAX-WS service interfaces you may reuse them in the client via

YourInterface service = Service.create(...).getPort(YourInterface.class);

If you just want to reuse your data classes there is a tutorial on that: How to make a JAX-WS client reuse existing classes for data binding

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