How setup java-first webservice client-jar in Maven? - java

Need some advice on how to setup maven-build
of the client-jar for java-first webservices...
Previously, I have been working with wsdl-first webservices,
where you simply save the wsdl in version-control
and then generate the java client classes from it.
But recently I switched to another project,
where most webservices are already existing as java-first,
and we should now convert the builds from Ant to Maven.
What is the best way to set this up in maven and version-control
to ensure you get the latest version of the wsdl?
Obviously you dont want to save the wsdl into version-control,
since it is generated at runtime...
I guess one way is in your maven-build to start app-server on localhost,
deploy the webservice to it,
then build the client-jar from the localhost-url.
Problem is the build might then fail if some dependencies
(db-connections, other webservice, etc) are not available at build-time.
So is there some better way to do this?

I guess one way is in your maven-build to start app-server on localhost, deploy the webservice to it, then build the client-jar from the localhost-url.
Instead you could use maven wsgen plugin to generate the client artifacts in the directory of your choice. wsdl generation would be optional here.

There is nothing wrong in checking in the WSDL in version control. every time some one changes the public methods they need to update the WSDL manually or else your option of doing it by deploying it to local host is also nice idea but the client-generation would not be that frequent so you can rely on this too.

Related

Maven EAR project distribution for multiple application server?

I have a maven project which generate zip generated from ant scripts. Then this zip is deployed to specific application server again using ant script. this is very complex for maintenance. Now we move to use maven for building zip, so what is standard way to doing with respect to developer and client
How to handle application server specific deployment(e.g for weblogic and jboss) Do I need to create 2 zip for each server?
How to handle global configuration parameter like database, product specific settings. Where to put them, and how it use by developer and client?
The installation of application sever is need to integrate with build cycle or what is best practice for it?
I'll try to answer based on my experience:
I use maven profiles for this. Especially since there are beans (classes) that are specific to only one app server at a time. See http://maven.apache.org/guides/introduction/introduction-to-profiles.html
maven supports placeholders. One build for every single environment: dev/qa/prod,etc. All you need is the properties file. (this is similar to properties in ant)
You do not need (usually, unless you have integration tests that are tight to the app server - and if you do, it seems wrong) an app server for the build itself.

Hot Deploy to multiple tomcat servers

I want to deploy a WAR to multiples tomcat servers (they may change) and do this from a java project.
I've searched and i find cargo, but in cargo i need to know all the servers were i want to deploy my WAR and create a config file with them. The thing is that those servers will change for sure in my enviroment (i may add some, remove some or modify some).
Is there any way i can do what i want?
i'll repeat what i want: From an java app deploy a WAR to a list of tomcat servers (running servers)
PS: sry for my english
EDIT:
this is an example of what i want to do:
Every tomcat its independent from the rest, its like ATM's and i want to "update" their "software" every time in a while, an ATM may be removed or added. so the number of ATM's to update may change
Why don't you publish your WAR file into a Maven repository and then use that as a platform for deployment? See the diagram in the following answer:
Should Artifactory NOT be used to capture the build artifacts that Jenkins produces?
This approach would neatly decouple the process that builds your software from the process(es) that deploy your software. Specifically you won't have to track your deployments in Maven anymore.
You can try with maven-deploy-plugin: http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploy-ftp.html
You can configure where to put WAR file, there are possibilities to deploy using ssh or ftp protocol.
If you're running your Tomcats in a cluster, use the FarmWarDeployer.

Want to upload war automatically on server if something get changed on local

I have been working on 3 Java Spring and Hibernate projects at a time. Every time if I make any changes on any of these three project then I have to create build again and manually I upload three builds to three different servers.
Is there any mechanism to avoid this manual process? Is there a tool or script that can check if I make changes to my code in Eclipse and save the files which will then commit the code and automatically build and upload the war file to the appropriate server?
This would save me a lot of time.
You need continous integration. Maven is a build tool and won't deploy on change.
Whereas a CI tool such as jenkins will listen to your code reposiotry and every time a file is commited it will call then call whatver maven command you wish.
However re-reading your question, it looks like all you really need is a hot deploy development enivronment. Which is quite easy.
If the projects are on maven, there are plugins for all major application servers.

Jar files required to Invoke Webservices

I have ported jamvm to my armel device. I am able to run various swing based and communicate to other systems via socket programming method. But when I try to call a webservice I get many NoClassDefFound exceptions.
I placed jaxws-api.jar file to remove some such exceptions which directed me to other class definition not found exceptions.
Can someone please tell which arfe all the necessary jar files are required to be present during runtime in order to invoke a webservice on a server machine.
Thanks in advance.
If you are using net beans IDE to develop the restful service it is very essay. Just follow these instructions all library (including Jersey) will be added to your project. If you need to get the library separated take the lib folder in project path.
http://netbeans.org/kb/docs/websvc/rest.html
p.s : You don't need to create DB though.

How is build-wsdl2java.xml generated?

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

Categories

Resources