wsimport for generating a Java WS-client
So how did I miss this tool?
I have been using JDeveloper for a few years now and am impressed with the IDE for Oracle development. Recently however I have been doing a fair amount of vanilla Java programming. I switched IDE’s to eclipse and see why it is so popular. I now use both IDE’s depending on the task at hand. What I liked about JDeveloper were the generation tools. What I do not like about JDeveloper is how bad the code is that they produce and how it masks a lot of the internals. I find that to get something done initially, JDeveloper really fits the bill well. Then as I understand more about what I am doing and what JDeveloper is doing for me, I tend to switch out a lot of what JDeveloper does for me.
However, in the eclipse space things are not as smooth. I do not like Apache Axis. It has been a headache for me whenever I have to deal with it. Both methods are cumbersome and irritating and produce too much code in my opinion. I was about to resort to building my own tool for generating my own SOAP envelope and making a URL connection to do the call. I was not too keen on the idea and did a bit of googling and found wsimport. It is simple fast and produces minimal code. I really like it. It is not fully featured like axis, but gets the job done for what I want to do. It is easy to extend it to do asynchronous calls and is relatively clean in comparison to the other two methods I have worked with.
BEST OF ALL no library includes! okay… I had the minimal libraries already in my path
This is going to be the way I generate my clients going forward. I will blog again if I have any issues with it. What I hate about the Java world is that many of the libraries try to be everything to everyone (A factory to produce factories… I mean seriously!). Just like the language, this makes the library cumbersome and verbose to work with. Have a look at the security on Blackboard Webservices for an example of how to do it right, but at the same time make it a ball-ache to integrate with.
To run command-line arguments from maven, you need the exec-maven-plugin:
<plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>wsimport</executable> <!-- optional --> <workingDirectory>tmp</workingDirectory> <arguments> <argument>-keep</argument> <argument>http://server.example.com/context-root/service?wsdl</argument> </arguments> </configuration> </plugin> </plugins>
EDIT: the command was already in my path… I assume it is std with the JDK
EDIT: here is the documentation http://download.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html