Skip to main content

XML post to URL

No replies
vaskarbasak
Offline
Joined: 2007-07-06

Hi All,

I have to post the xml data to a specific URL.But i got an error msg.

I'm trying something like this :

package com;

import java.io.*;
import java.net.*;
import org.w3c.dom.*;
import javax.net.ssl.HttpsURLConnection;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.dom.DOMSource;

public class Main {
public static void main(String args[]) {
String targetURL =
"https://pubdev.auctions.overstock.com/cgi-bin/auctions.cgi?";
String marchentid = "xxxxxxxxxxxxxxxxxx";
String authid = "eeeeeeeeeeeeeeeeeeeee";
URL website = new URL(targetURL);
URLConnection connection = website.openConnection();
connection.setRequestProperty("Content-Type", "text/xml");
connection.setDoInput(true);
connection.setDoOutput(true);

PrintWriter out = new PrintWriter(connection.getOutputStream());
out.println("<?xml version=\"1.0\"? encoding=\"iso-8859-1\">");
out.println("");
out.println("");
out.println("" + marchentid + "");
out.println("" + authid + "");
out.println("IsUserLoggedIn");
out.println("");
out.println("");

out.close();

BufferedReader in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String inputLine;

while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);

in.close();
}

} catch (Exception ae) {
ae.printStackTrace();
}

}
}

Error:-

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
at com.Main.main(Main.java:48)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
... 13 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 19 more

I am using JSDK 1.4.

Pls help me.

Thanks!