How can I access the exposed methods in a
.wsdl file using Java? Also, what are the steps involved in writing a Java client and consuming the webservices?
In addition to The Elite Gentleman's answer, here are my steps I successfully used to generate classes to be able to use the webservice: Command:
wsimport -Xnocompile -keep -b binding.xml wsdlFile.wsdl
- '-Xnocompile' suppresses the generation of .class files
- '-keep' makes sure the generated Java files wont be deleted (by default, only the .class files remain)
- '-b ' specifies a binding configuration file. This is necessary! (see below)
I had the problem that the Java classes contained the
JAXBElement<Type> wrapper classes. So instead of a class member of type
String, I would get the type
JAXBElement<String>, which is horrible to use. With the
-b switch for
wsimport and the following
binding.xml file, you get the correct types:
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jaxb:bindings> <jaxb:globalBindings generateElementProperty="false" /> </jaxb:bindings> </jaxb:bindings>
I hope this helps.
wsimport then generates all the classes you need as well as a class containing methods for all your webservices' methods.
By default, these methods don't have a read timeout (talking network problems while requesting...), see here for a question I had back then.