Could we try to distinguish classes, objects and services.
You have something like this?
@javax.jws.WebService
public class ServiceAAA{
public String echo(String arg) {
// some really nice code here
}
}
and you want to add
@javax.jws.WebService
public class ServiceBBB{
public String superEcho(String arg) {
// even more code here
// which needs to reuse the code from A's echo()
}
}
So clearly we don't want to cut and paste between the two implementations. How do we reuse?
Alternative 1:
Directly call A from B. You are asking how to do that. It could be done. You would just code a JAX-WS client call in your implmentation. However I stringly recommend against this. A service call is likely to be more expensive than a simple Java call.
Only do this if y6ou don't have the option of deploying the two service classes together.
Alternative 2:
Refactor the implementation. Just move the code into a worker class.
@javax.jws.WebService
public class ServiceAAA{
MyWorker worker = new Worker();
public String echo(String arg) {
return worker.doSomething(arg) ;
}
}
@javax.jws.WebService
public class ServiceBBB{
MyWorker worker = new Worker();
public String superEcho(String arg) {
worker.doSomething(arg) ;
// and some morestuff
}
}