wsimport was coming as default in bin folder in jdk till 8 but now it is not shiped by default.
But you can download the same from below location.
https://repo1.maven.org/maven2/com/sun/xml/ws/jaxws-ri/2.3.1/jaxws-ri-2.3.1.zip
in bin folder of above zip you will get wsimport.
Now as we dont have WSDL file we are using readymade WSDL file.
https://svn.apache.org/repos/asf/airavata/sandbox/xbaya-web/test/Calculator.wsdl
Now lets import the same in soapui tool and create mock up for sending reponse as shown below.
Now create a simple java project in eclipse and belwo command to create the java client code using wsimport command.
wsimport -keep -d C:\eclipse-j2ee-workspace\ConsumeSoap\src -p com.siddhu file:/C:/eclipse-j2ee-workspace/ConsumeSoap/resource/Calculator.wsdl
now create lib folder and place all the required jar in it that is shipped by defualt in jaxws-ri-2.3.1.zip.
Add all the jar of lib folder in projec class path.
Now create the below main class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /** * */ package com.siddhu; import javax.xml.ws.WebServiceRef; /** * @author Siddhartha * */ public class SiddhuMain { public static void main(String[] args) { try { SiddhuMain client = new SiddhuMain(); client.doTest(); } catch(Exception e) { e.printStackTrace(); } } public void doTest() { try { Calculator objCalculator = new Calculator(); System.out.println("Retrieving the port fromthe following service: " + objCalculator); CalculatorPortType port = objCalculator.getCalculatorHttpSoap11Endpoint(); System.out.println("Invoking the add method the port."); Integer response = port.add(new Integer("1"),new Integer("2")); System.out.println(response.toString()); } catch(Exception e) { e.printStackTrace(); } } } |
Final execute it and you will find the response as given below.
OutPut:-
Retrieving the port fromthe following service: com.siddhu.Calculator@4450d156
Invoking the add method the port.
4
Note: you can download the code from below github location.