Solved

Call a web service from java (eclipse)

Posted on 2012-12-24
6
500 Views
Last Modified: 2013-01-01
How can I simply call a web service from java (eclipse)?
0
Comment
Question by:tcorigli
  • 3
  • 3
6 Comments
 
LVL 26

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 26

Accepted Solution

by:
mrcoffee365 earned 500 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 26

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 64
wordcount challenge 11 76
best (free) software to access postgres db (java) 1 18
create a gui in perl 3 45
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now