Calling a SOAP web service. In this article we will call a web service provided from detail we will call the currency convertor WS, calling it by means of Soap-UI; after using wsimport we will  generate the client classes, hence making a simple main we will call the service and integrate it in our simple project.Why that ?When a developer or architect try to call a ws and he got an error …the panic diffuses over the air.One simple pragmatic approach can be:1 - Retrieve the Url of the ws.2 - Try it with SoapUI. 3 - Use wsimport to create the client.4 - Make a simple public staic void main to call it (another test) 5 - Integrate it. What ? Five  steps to ingrate a soap ws ? Sometime the long  path is the shortest path. Let’s go. We will call a service provided from Surfing the site we can find out CurrencyConvertor service. After retrieved the url and created a new project under SoapUI put the url in the Initial WSDL field. Url to insert: and choose a whatever name you want for the project. After that,  try calling the service CurrencyConvertorSoap, maybe inserting EUR as first parameter and USD as second parameter. You’ll see something like that. If all went OK, you’ ll see the response from site.
written by Ivan Cerrato
back to home
JEE Tomcat Eclipse Web Service SOAP wsimport SoapUI
Hence, at this poiny of history, we verified that the url was correct and all that there’s a free network connection betwenn client and ws. Several errors on calling web services are due to  network problems: firewall , static route and similar things. Now it’s time to use wsimport. Choose a directory from your os and make new dir, for example aaaa. Go inside the new directory and type  wsimport -extension -Xnocompile Warning. This is the right syntax for Mac OSX, but you’ll type a similar command under linux o similar. Launching the command something like that will appear   At his point you’ll obtain a new folder called net with a hierarchy inside containing the java files. Now open Eclipse and crete a new java project. Copy the net package inside the project and create a new simple class,  for example Class_1. Add a  public static void main(String[] args) { and inserting  the  wsdl in the browser retrieve the following parameters: targetNamespace. The portType name. The service  name.
JEE Tomcat Eclipse Web Service SOAP wsimport SoapUI
The project in eclipse will appear similar to the following picture: Create a simple method  void run_service() and run it from the main. The method have to make the url  URL url = new URL("");  make the QName  QName qname = new QName("http://www.webserviceX.NET/", "CurrencyConvertor"); instantiate the service and use it Service service = Service.create(url, qname); CurrencyConvertorSoap cc_service =  service.getPort(CurrencyConvertorSoap.class); double ret = cc_service.conversionRate( Currency.EUR,  Currency.USD); System.out.println("the ret is: " + ret); Ok, you’ ll obtain something like that That’s all. See the download setion for the project zip.
Download section.