Thursday, July 25, 2013

Java WebService Tutorial - Part 06 ( Using wsimport tool to generate Client and accessing a Webservice )

In this tutorial we will see how wsimport tool can be used to generate java classes from a wsdl and how we can access a webservice easily like normal java applications.

wsimport :

This tool is come along with the jdk.If you have install the JDK properly and your classpath or JAVA_HOME variable is set you can see the list of options provided by this command  by typing wsimport in the command prompt.

For generating Java classess from wsimport the syntax is :

wsimport  wsdl-location-path  -d -keep

The wsdl-location-path : Is the location of wsdl file existence.

-d : specify the directory where all the generated classes should be placed.

-keep : It will keep the java source code of generated classes in the respective directory mentioned.

-extension :allow vendor extension - functionality if not have been specified.


wsimport  hello.wsdl   src  -keep

Now we will take the sample webservice of w3schools which has the follwing wsdl location:

Execute the command in DOS Prompt to generate classes from wsdl :

 C:\webservice> wsimport -extension   -keep

After execution it will create a folder called org inside the webs service folder.

Now Create a Main class to access these webservice :


import org.tempuri.*;

 public class Main {
    public static void main(String a[])
        TempConvert convert=new TempConvert();
Save these class inside "webservice" folder .Compile and run it you will see the output as "251.6" returning from web service.

Result :

<<Prev          Index            Next >>                 


Technology Blogs


  1. Replies
    1. Great Article android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Not working error:

    Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: com/w3schools/webservices/Main)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at Source)
    at Source)
    at$100(Unknown Source)
    at$ Source)
    at$ Source)
    at Method)
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

  3. Hi there everyone, it's my first visit at this site, and piece of writing is in fact fruitful for me, keep up
    posting these articles.

    My webpage Beats By Dre UK

  4. It's impressive that you are getting thoughts from this article as well as from our argument made

    Feel free to visit my blog post :: Dre Headphones

  5. Hello! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form?
    I'm using the same blog platform as yours and I'm having problems finding one?
    Thanks a lot!

    My blog post - Running Shoes

  6. Heya i am for the first time here. I came across this board and I find
    It truly useful & it helped me out a lot. I hope to give something back and aid others like you
    helped me.

    Feel free to surf to my website: New Balance
    Discount (

  7. It's difficult to find educated people about this topic, but you sound
    like you know what you're talking about! Thanks

    Check out my webpage ... Fake Louis Vuitton Bags

  8. I really like looking through an article that will make people think.
    Also, thanks for allowing for me to comment!

    my web blog - Christian Louboutin Boots

  9. Hi, i think that i saw you visited my website so i came to “return the favor”.I'm trying to find
    things to enhance my website!I suppose its ok to use
    a few of your ideas!!

    My web page - New Balance Shoes

  10. Hey There. I discovered your weblog the use of
    msn. That is a really neatly written article.
    I will make sure to bookmark it and come back to read more of
    your helpful info. Thanks for the post. I will definitely return.

    Take a look at my page ... New Balance Minimus

  11. Thanks for your valuable posting.I have collect more than information from your website. It is really wonderful blog. please added more than tips. i'm working in Erp in india.Here providing very low price and Quality ERP,Cloud ERP, CMS , responsive webdesign and ERP. you have any more than information kindly make me call this number 044-42127512 or send your mail

  12. Getting below mentioned error:

    empconvert.asmx?WSDL -extension -keep
    parsing WSDL...

    [ERROR] Failed to read the WSDL document:
    empconvert.asmx?WSDL, because 1) could not find the document; /2) the document c
    ould not be read; 3) the root element of the document is not .

    unknown location

    Failed to parse the WSDL.

    kindly help to resolve the issue

  13. Can you provide small example for wsimport JAXB option -b/-B

  14. This tool is faster and easier for analyzing thread dumps, which might actually be worth trying.

  15. Thank you for your precious information. very clear explanation.Please share more like that..
    Automotive erp software in chennai

  16. Amazing Article ! I have bookmarked this article page as i received good information from this. All the best for the upcoming articles. I will be waiting for your new articles. Thank You ! Kindly Visit Us @ Coimbatore Travels | Ooty Travels | Coimbatore Airport Taxi | Coimbatore taxi

  17. This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
    Devops Training courses
    python Training in chennai
    Devops Training in Bangalore

  18. I appreciate that you produced this wonderful article to help us get more knowledge about this topic.
    I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!

    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training
    Selenium interview questions and answers

  19. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
    Python Online training
    python Course institute in Chennai
    Python Course institute in Bangalore

  20. Such a great information for blogger iam a professional blogger thanks…

    Upgrade your career Learn Oracle Training from industry experts gets complete hands on Training, Interview preparation, and Job Assistance at Softgen Infotech.

  21. Computer Full Form is very usefull in students for study in education

  22. E shram Card is a labor registration portal created by the Labor Department, Government of india.

  23. KGF 2 : Directed by Prashanth Neel. With Yash, Sanjay Dutt, Raveena Tandon, Prakash Raj. The blood-soaked land of Kolar Gold Fields

  24. All type services start in Bihar Govt go to see this services and help for filling form RTPS Bihar

  25. Welcome to CapturedCurrentNews – Latest & Breaking India News 2021
    Hello Friends My Name Anthony Morris.latest and breaking news

  26. I really enjoy the article.Thanks Again. Fantastic.
    net coure
    net training

  27. These are very good post and i like your post...hindi skill