• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Posting values to HTTPS Url

 
nishad km
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

From my applicaiton we need to access an external url for mail servcice.we will have to establish the connection with this server and POST the values to this server. The external Server URL is in HTTPS, and requires a basic authentication.

the code is given below. I am getting error :java.net.ConnectException: Tried all: 1 addresses, but could not connect over HTTPS to server: "domainname" port: 443

java.net.URL url = new URL("https:\\domainname\...\index.php");
HttpsURLConnection connection = new HttpsURLConnection(url);
String userNamePassword="username assword";
String encoding= new BASE64Encoder().encodeBuffer userNamePassword.getBytes());
connection.setRequestProperty("Authorization","Basic "+encoding);
connection.setTimeout(wom_connection_timeout);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoOutput(true);

Can any body suggest a way to connect to a Server through https url and pass the post variables?

thanks,
Nishad

[ October 30, 2008: Message edited by: nishad km ]
[ October 30, 2008: Message edited by: nishad km ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You aren't really using "domainname" as the server name, are you?

Is the server reachable by HTTP from the machine this code runs on?
 
nishad km
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am able to connect to that Url through browser( https- http will not work)but through application i was not able to.

Can you tell me how to post the values? is it same as the urlparameter like
&name=nishad&action=queue.. Or we need to ecrypt the values
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you connect to any other server by HTTPS using code similar to that?
 
nishad km
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i am not able to connect any https urls, as the request goes through our proxy server and in proxy server https is not enabled. thanks for the help.

But can you tell me username and password for authentication should be in encrypted format or not when post the request? if we send the other values as query string(name=nishad) will it be fine?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But can you tell me username and password for authentication should be in encrypted format or not when post the request?

The username/password stuff looks OK as it is. A good test for this is to try it with an HTTP URL instead of an HTTPS URL.

if we send the other values as query string(name=nishad) will it be fine?

That depends on the server-side. There's nothing like a bit of trial-and-error :-)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic