Consider there are two web services Test1 and Test2 sitting in the same server in same project. There impl classes are Test1Impl and Test2Impl. Test1Impl contains definition of a method getDetails and Test2Impl contains a method addDetails.
Now I want to call addDetails in Test2Impl from getDetails in Test1Impl.
I get following ideas to implement this functionality
1) since these services impl classes are sitting in same project can I call it as a noramal java method like
new Test1Impl().addDetails(request)
this will break web service limitation.
2) I should make web service call to invoke that method. This will become nasty because the It will be hitting the network and making web service call to a service sitting in same server moreover in same project.
ServiceLocator.getTest1Services().addDetails(request);
3) implement same method in addDetails in Test1Impl as a private method.
public class Test1Impl{
public Response addDetails(Request request){
//
//
}
}
public class Test2Impl{
public Response addDetails(Request request){
//
//
}
}
This will be redundant of code and it will decrease the code standard.
Please help me which way to go,even new ideas are welcomed.
I think you are mixing concerns in your design: you should refactor the business logic away from the web service interface/public exposure/transport logic. Perhaps have a
DetailsServicebusiness service class (not a web service!) that hasaddDetailsandgetDetailsmethods that the services call as necessary. This way you will have no duplicated code and you are still keeping the read and write operations separate at the web service interface level.I like to keep my web service classes as small as possible and responsible only for passing information on to my business service layer. This means that if you were to add a GUI to your application that the business logic is already coded and you can just hook your new GUI into the
DetailsService.