Home » Developer & Programmer » JDeveloper, Java & XML » Unable to access URL using HttpURLConnection
Unable to access URL using HttpURLConnection [message #498163] Wed, 09 March 2011 01:06 Go to next message
Messages: 22
Registered: December 2010
Junior Member

I am using HttpURLCOnnection class to post a data to a url(which is a web service). The webservice accepts data as text/xml.

Following is the code snippet i used:

URL url = new URL("http://xxx.xxx.xx.xx:8080/SampleWebService.svc");
HttpURLConnection conn =(HttpURLConnection) url.openConnection();
String urlStr="param1="URLEncoder.encode(value1)"&param2="+URLEncoder.encode(value2)
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
InputStream in2 = conn.getInputStream();

But when i execute the code, I am getting following error at the line(InputStream in2 = conn.getInputStream()wink.gif

java.io.IOException: Server returned HTTP response code: 400 for URL

Can someone please suggest a solution. Am i missing something here?

Thanks in advance
Re: Unable to access URL using HttpURLConnection [message #498165 is a reply to message #498163] Wed, 09 March 2011 01:13 Go to previous message
Michel Cadot
Messages: 68664
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This question bears no real connection with Oracle.
Please find a more appropriate forum.
The topic is locked.
If I'm wrong, please, PM me (or report this message to a moderator, explain why you think it should be unlocked and it might be done).

Previous Topic: Query XML Data (2 Merged)
Next Topic: command line arguments...
Goto Forum:

Current Time: Thu Jun 20 17:42:45 CDT 2024