I have been given a WSDL file and I need to consume a web service using this WSDL file over the internet. I need to do this in Java.
Could someone tell me the steps for doing this? I would also appreciate some useful links.
I'd use JAX-WS (please, please, forget Axis or Axis 2, see previous answers) and the good news is that Java 6 includes JAX-WS RI so you already have everything required, nothing to do. In other words, just use wsimport
to generate the classes required to call the web service.
Example:
wsimport -p stockquote http://stockquote.xyz/quote?wsdl
This will generate the Java artifacts and compile them by importing the http://stockquote.xyz/quote?wsdl.
Invoking the web service is then a matter of three lines of code (without including the initialization of WS arguments). See Creating a Simple Web Service and Client with JAX-WS in the Java EE tutorial, Getting Started with JAX-WS Web Services or Developing JAX-WS Web Service Clients for examples.
The first step is to generate classes that can speak to this webservice. Take a look at open source solutions such as Axis2. This will generate stubs for you to talk to the webservice in code... then it's all up to you to use this service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With