Instructing wsimport/jaxb to use existing model/domain classes

1k views Asked by At

I humbly ask for your help in step-by-step way.

I'm working on a project which is managed by apache maven. The project has several submodules

/pom.xml
/model/pom.xml
/server/pom.xml
/client/ws/pom.xml
/client/vaadin/pom.xml
  • server and ws depends on model
  • vaadin depends on ws

  • "model" project I have my hand-written domain classes which are annotated using JPA and XML annotations. Example below:

    package com.example.domain.auth;

    @Entity
    @XmlType(name = "User", namespace = "auth.domain.example.com")
    @XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD)
    public class User implements Serializable {
    
    @NotNull
    private String username;
    
    @NotNull
    private String password;
    
    @Temporal(value = TemporalType.DATE)
    private java.util.Date accountExpirationDate;
    
    public void veryComplexAction() { ... }
    
    // getters & setters
    

    }

  • "server" project hosts several WebServices which uses domain classes as both input and return types.

  • "ws" (client/ws) project is just a project with only WebService clients.

Project building is done copletly by maven. (wsgen & wsimport of wsdls using relative paths)

I don't have access to XSD files (well I do but) since they're generated during wsgen plugin execution on "server" project and have generated (semi-random) names which can change during development process since they're generated by wsgen.

Now since I have access to my model project I'd like to use it in "ws" and "vaadin" projects without the need to use generated model which don't have methods I've implemented in "model" project.

I have found that I need to use "episode" file to instruct jaxb compiler to skip generation domain classes.

The thing is I can't get it working because everyone give example where XSD is already available which in my project is generated during build process and contents of file "UserService_schema1.xsd" in next build can be in file "UserService_schemaN.xsd".

Acceptable solution:

  • generation of static xsd's during build process which have explicitly provided names and stay like this forever (even if regenerated) and using those xsd's generating episode files used in wsimport later or
  • any solution which is completly automatic that I could type "mvn clean package" and all will be done for me like: generating static xsd's, episodes, wsdls, web service client wrapper classes using domain model from "model" project. (no manual copying of java files or episode files)

What I'd like to get (and probably not only me) example project or step-by-step tutorial on how to reuse existing domain model in webservice client project which is managed as a submodule of maven project. It can be even with one class, interface, enum. Just simple POJO demonstrating on how to configure everything.

What I've already checked:

http://stackoverflow.com/questions/11745465/jaxb-my-own-domain-model-and-suggestions
http://stackoverflow.com/questions/15907973/how-to-remove-auto-generated-classes-in-jax-ws-clients/16007685#16007685
http://jamablog.blogspot.com/2007/08/how-to-make-jax-ws-client-to-reuse.html
http://jamablog.blogspot.com/2007/08/how-to-make-jax-ws-client-reuse.html
http://sr-it.eu/wordpress/?p=135
http://metro.1045641.n5.nabble.com/Reusing-entity-classes-with-JAX-WS-bottom-up-td1061083.html
1

There are 1 answers

0
user373201 On

We have a similar setup. We using eclipse link and apache cxf together with jaxws. We don't generate client side model. We are using existing domain objects. EclipseLink helps you to annotate domain objects in an XML file. since our domain objects are in a seperate jar, we don't annotate the domain objects but use an xml file in the ws project to specify how to interpret the domain objects.

I did not put it together so can't provide you with a step by step instructions.