I read somewhere it is not allowed, now it is hard to find why?
We have two different ear projects, say A and B. For a webservice, code generated using Apache Axis wsdl2java, client (stub/model) classes are in project A, and service implementation is in project B.
I had to restructure project A to have a new (maven) module with many packages/classes, which would create a library to be used by project B. Now, due to too many code dependencies, I could not get the webservice client code out of this module/library in project A (to put them elsewhere in project A).
Say the webservice (generated code) is in package a.b.c. In the generated code, client stubs, and the implementation class are all in this package a.b.c. Now the (webservice) implementation belongs to project B. As I had to include the client classes in the library of project A, and have the service classes in project B, then I will have the following situation
Library pulled into project B (from project A): a.b.c/client-classes
project B itself a.b.c/implementation class
Is this okay? Having the same package twice, but with different sets of classes.
If we cannot have this situation, then can we generate or have webservice client and service classes in two separate packages (like a.b.c.client and a.b.c.service)?
CodePudding user response:
With this approach, I went with and it solved my situation.
This is JAXWS webservice & JDK 8 & JBoss deployment (plain old technologies and non spring environment).
I used bottom up approach of webservice development (Java classes first - no handwritten WSDL). On the service side application, I wrote the interface and implementation classes, with minimal annotations like @WebService and @WebMethod. I have developed few (simple) model classes that are used for arguments and results of the service methods, but I did not put any annotations in them.
Then starting the application server brought the webservice to life (at a certain "URL").
Using the URL of the WSDL (url?wsdl), I used wsimport tool to generate client code. Note: I used -p option to give a different package for the client code. Then integrated the client code in the other application. Everything worked good.
This situation of client and service code to be in different (Java) packages, may be possible even with top down (WSDL first) approach as well, but I could not get it to working. May be it needs some careful hand wiring of WSDL and appropriately annotating the classes.