Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given a WSDL file, what are the steps to consume a web service over the internet?

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.

like image 999
Kaddy Avatar asked Mar 08 '10 19:03

Kaddy


2 Answers

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.

like image 78
Pascal Thivent Avatar answered Sep 28 '22 08:09

Pascal Thivent


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.

like image 38
Malaxeur Avatar answered Sep 28 '22 08:09

Malaxeur