?
Solved

How to send HTTP request to the Web Service

Posted on 2009-05-09
11
Medium Priority
?
579 Views
Last Modified: 2013-11-19
Hi, I am trying this code to send a HTTP Request to a Web Service to check whether the WebService is up or not at a given URL:

***********************

String requestUrl= "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
           
            try {
           
                  URL url = new URL(requestUrl.toString());
           
                 
                         HttpURLConnection aConnection = (HttpURLConnection) url.openConnection();
      BufferedReader buffer = new BufferedReader(new InputStreamReader(aConnection.getInputStream()));

                       String line = "";
                       while ((line = buffer.readLine()) != null)
                                                   {
                           System.out.println(line);
                       }

********************
But when I run the code, I get this exception:

java.net.UnknownHostException: www.w3schools.com

I can access this WSDL by typing the url in my explorer which means I have the connectivity to this URL. Any help on this, please?

Thanks
0
Comment
Question by:LeoKris
[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
  • 5
  • 3
  • 3
11 Comments
 
LVL 92

Accepted Solution

by:
objects earned 750 total points
ID: 24343132
check your browsers proxy settings and use them when you run your app

http://helpdesk.objects.com.au/java/how-to-tell-a-java-application-to-use-a-proxy-server
0
 

Author Comment

by:LeoKris
ID: 24343299
There is no proxy setting in my internet explorer..it is not "checked" and there is no script configured too.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24343480
Perhaps you have DNS problems. Try

String requestUrl= "http://216.128.29.26/webservices/tempconvert.asmx?WSDL";
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:LeoKris
ID: 24343635
oh..thanks for pointing that out.. I will try and let you know.
0
 

Author Comment

by:LeoKris
ID: 24347496
strange thing happened... I tried the same code in IntelliJ IDEA and it works like magic... it works with the dns name i.e. www.w3schools.com.

Don't know what is the difference between the IDEs.

Anyway, thanks a lot CEHJ.
0
 
LVL 92

Expert Comment

by:objects
ID: 24347553
Could be a problem with then Network settings in the IDE
Or just a tempoeaey network glitch
0
 
LVL 92

Assisted Solution

by:objects
objects earned 750 total points
ID: 24347558
The code itself is fine
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24347563
Has the original problem disappeared too, or is it still there?
0
 

Author Comment

by:LeoKris
ID: 24347583
The original problem is still there, The other IDE I am using is eclipse but in a different laptop. Something to do with Network settings probably.
0
 

Author Closing Comment

by:LeoKris
ID: 31579891
Thanks for pointing in the right direction.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24347646
>>Something to do with Network settings probably.

I'm wondering why you've accepted an answer if the problem remains undiagnosed ..?
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

649 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