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
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.
Related
In a very big Java app with lot's of DTOs, I want to export to an external project only the DTOs that are relevant to REST calls, and even better to export a part of them (the minimum required for REST calls).
The project uses Swagger and I am wondering if it is possible to take the output of Swagger (uses Java DTOs to create JSON\YAML files), which have the exact content I need, as an input to generate new Java DTO files. The generated files will be only those needed for REST and I will be able to easily export them.
Is this possible?
If not, what is the best approach to do that?
Maybe check out swagger.generator.io where you can generate a whole client library (including DTO classes) for your specified swagger definition file. For documentation please refer to their github page. You can also do the generation of the API client locally utizing the swagger codegen tools.
Is it possible to have a multi module Maven project using JHipster?
At first sight seems not but I want to know if there's a way to share common classes like domain classes or repository classes among different web modules in my Project using Maven.
Suppose to have a Web module with an HTML GUI made with Thymeleaf (no React / Angular), a classic Backoffice.
Then I want to have another web module that expose some REST API that needs for the same domain classes and the existing repository layer.
At first It seems that I've have to duplicate these classes and code into another JHipster application but obviously It's not the best solution.
Without JHipster I create a multi module Maven project with 2 web modules (Backoffice + API) and a third module with these common classes packaged in a shared JAR included as dependency in the first two modules.
How (if It is possibile) can achive this with JHipster?
Thanks
JHipster won't be able to generate what you want, it's up to you manually refactor the generated project to suit your needs and it's not difficult because JHipster puts entity classes in domain package and repositories in repository package. You will then have to decide how you want to execute the Liquibase migrations.
You can generate only backend code using --skip-client option, see command line options in doc.
An alternative (if you are motivated) would be to write a JHipster blueprint to generate a project with the structure you want.
How do you organize WSDL based Web Services in Java at project structural level?
Personally I like to store the WSDL in a distinct maven module or project, which is built into a JAR. The resulting JAR contains the WSDL, SEI, client and JAXB classes. Of course the java class generation is automated by the build. Then I can just add the artifact as a dependency to any dependent project. Now, if I need to change the service, I only have to edit the WSDL and build the project. Re-generated java classes are then propagated to all service consumers by the dependency management.
Is this the best way to organize WSDL's? Are there some drawbacks in this approach at certain situations I haven't thought of, or would some other approach provide some additional value?
I'm writing a web service using jax-ws. One of web service's methods returns bean, which contains reference to its parent. To prevent cyclic references I'm using JAXB #XMLID and #XMLIDRef annotations in my bean.
Then i'm generating proxy class for java client everything works OK and id resolves to Object properties. But then I'm generating web-service client proxy in Visual Studio for .NET, it interprets idrefs as string properties, not an Object.
Is it possible to generate proxy classes from wsdl for .NET with resolving of idrefs?
Out of the box Microsoft's tools won't do the job for you. You'll have to ask Microsoft to change the
wsdl generation tools. E.g.:
wsdl.exe: http://msdn.microsoft.com/library/7h3ystb6(VS.80).aspx
svcutil.exe: http://msdn.microsoft.com/en-us/library/aa347733.aspx
In a recent project I had to work around the short comings of these tools and modified the generated code using a Basic Script fixing what was not generated the way needed (in our case incompatibilities with the Java side wsdl generation)
I've inherited the code base for a Java application which talks to a few SOAP web services. Proxy classes to do this are generated using an ANT task calling wsdl2java. As my Java experience is quite limited, I'm still trying to get my head around exactly how this all works.
There is a build-wsdl2java.xml file in the project that seems to contain the configuration information required for the class generation. The file as it stands currently has attributes that aren't currently supported (namespacesmapfile, overWriteTypes, testcaseoverwrite), but if I attempt to resolve this by changing the first to 'namespacemappingfile' and removing the others, the attributes revert back if the project is cleaned. The URL for the WSDL also reverts back if it is changed.
What controls the generation of this file, and where do I define the configuration parameters that it contains?
Finally found out what was controlling this and, more importantly, have got things compiling again. I'm using JBuilder 2008 (an Eclipse based Java IDE from Embarcadero Technologies), and it would appear the client proxy classes were generated from the WSDL by using JBuilders built in support for this, which is effectively a wrapper for wsdl2java as mentioned by Noergaarde.
In order to set settings such as the URL for the WSDL, I had to switch to the Modeling perspective, and use the Model Navigator to change the URL, by selecting the class under the Web Service Client node and using the Properties view.
When you do a build of your project, does the timestamp of build-wsdl2java.xml change? ie. is this file generated by the build in another ant file?
At any rate, it certainly sounds like your client stubs are generated using AXIS.
http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL