Hi All,
I have a .wsdl file i need to access the exposed method in it using java,how can i do it,i am new to webservices so not getting it what are the steps involved to write a java client and consume the webservices ,pLease let me know
Hi All,
I have a .wsdl file i need to access the exposed method in it using java,how can i do it,i am new to webservices so not getting it what are the steps involved to write a java client and consume the webservices ,pLease let me know
I would recommend starting with the Web Service Explorer in Eclipse JEE. This allows you to investigate any web service given the WSDL.
The instructions to convert the WSDL to Java depends on which web service library you want to use. If you use Java 6 the Metro stack is built in.
You will need to need to generate a Java proxy from the WSDL File. You can do this by using Apche CXF or Apache Axis/Axis2 to generate Java Proxy/Java Client.
In Java 6, you can also generate java client too. On the JDK/bin there's wsimport to generate Web Service client or in Axis, there's WSDL2Java that does the same thing like wsimport.
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
Explanation:
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 dont have a read timeout (talking network problems while requesting...), see here for a question I had back then.
I would take a look at getting your IDE to automatically generate everything.
In Netbeans, the steps are:
Right Click on your project, click "add Web Service Client", enter the WDSL url and click Finish.
This will auto-magically create the Java proxy for you.
To implement the client in your code, drag and drog the required method (located in Web Services References in your project), into your code.
soapUI is one of the softwares allowing you to easily get into WSDL / SOAP world. You can generate SOAP requests with test values to be sent to the server. You can also see the server's SOAP responses. This will let you understand a bit more of WSDL / SOAP. For generating the java code from the wsdl see the recommendations above.