Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Call a web service from java (eclipse)

Posted on 2012-12-24
6
Medium Priority
?
519 Views
Last Modified: 2013-01-01
How can I simply call a web service from java (eclipse)?
0
Comment
Question by:tcorigli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 38719293
You make an httpservletrequest:
http://docs.oracle.com/javaee/6/api/index.html?javax/servlet/http/HttpServletRequest.html

Most people use the Apache commons HttpClient as a wrapping package, since it handles redirects and cookies:
http://hc.apache.org/httpcomponents-client-ga/index.html
0
 

Author Comment

by:tcorigli
ID: 38719735
Thank you for you reply, but I'm looking for an example or tutorial that shows me step by step how I simply can call an external web service from java (eclipse).
0
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 1500 total points
ID: 38733638
In that case, it's an easy online search.  For example:
http://technology.amis.nl/2011/06/29/how-to-call-a-call-a-webservice-directly-from-java-without-webservice-library/

We could help more if you had some code you were trying.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:tcorigli
ID: 38734188
Hi mrcoffee365,
Thank you for the link. I have tried to execute the code, but I'm receiving the following error message:

Exception in thread "main" java.lang.ClassCastException: org.apache.xerces.dom.DeferredDocumentImpl cannot be cast to javax.swing.text.Document
      at WebServiceCall.parseXmlFile(WebServiceCall.java:126)
      at WebServiceCall.getWeather(WebServiceCall.java:93)
      at WebServiceCall.main(WebServiceCall.java:33)

The code is attached.
Your assistance is greatly appreciated.
WebServiceCall.java
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 38734917
The exception is pretty clear.  This line, 126 in your program:
  return (Document) db.parse(is);

is trying to cast the results of DocumentBuilder db.parse method to a Document type.  So check the return type of the db.parse method, and cast it to the correct type or convert it to what you need.
0
 

Author Comment

by:tcorigli
ID: 38735119
Thanks mrcoffee
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question