How do you convert WSDLs to Java classes using Eclipse?
I have a WSDL file (or, more precisely, its URL). I need to convert it to Java classes. I also need to provide tests for the web service it describes. I'm new to web services, so could someone tell me how to convert WSDLs to Java?
I use Eclipse JEE Kepler. Maybe there are some plugins to do this automatically?
Solution 1:
In Eclipse Kepler it is very easy to generate Web Service Client classes,You can achieve this by following steps .
RightClick on any Project->Create New Other ->Web Services->Web Service Client->Then paste the wsdl url(or location) in Service Definition->Next->Finish
You will see the generated classes are inside your src folder.
NOTE :Without eclipse also you can generate client classes from wsdl file by using wsimport command utility which ships with JDK.
refer this link Create Web service client using wsdl
Solution 2:
You need to do next in command line:
wsimport -keep -s (name of folder where you want to store generated code) urlToWsdl
for example:
wsimport -keep -s C://NewFolder https://www.blablabla.com
Solution 3:
I wouldn't suggest using the Eclipse tool to generate the WS Client because I had bad experience with it:
I am not really sure if this matters but I had to consume a WS written in .NET. When I used the Eclipse's "New Web Service Client" tool it generated the Java classes using Axis (version 1.x) which as you can check is old (last version from 2006). There is a newer version though that is has some major changes but Eclipse doesn't use it.
Why the old version of Axis matters you'll say? Because when using OpenJDK you can run into some problems like missing cryptography algorithms in OpenJDK that are presented in the Oracle's JDK and some libraries like this one depend on them.
So I just used the wsimport tool and ended my headaches.
Solution 4:
Options are:
- Wsimport from Oracle uses JAXB
- Axis from Apache
- CXF from Apache
- Axis2 from Apache offers choice between ADB (default), Apache XmlBeans, or JiBX for data-binding
Read through the above links before taking a call