Hello Folks,
We built a simple JRS report against DataWarehouse which returns the result based on the input parameters. And then we exported the result to excel, copied the URL and queried the URL via java code and got the same results.
Example URL: https://dns.com/rs/query/2465/dataservice?limit=-1&basicAuthenticationEnabled=true&pName=ProjectIds&pName=parmVar_0&pName=parmVar_0&report=2451&pVal=201&pVal=351&pVal=422
But when we built a similar report against LQE, copied the URL from excel export, and tried querying the URL, but in this case the results are not returned. Please find the sample code:
InputStream inputXml = null;
try {
URL url = new URL(
"https://dns.com/rs/query/679/dataservice?limit=-1&basicAuthenticationEnabled=true&pName=ProjectIds&pName=parmVar_0&report=669&pVal=https%3A%2F%2Frb-alm-05-d.de.bosch.com%2Fccm%2Fprocess%2Fproject-areas%2F_HxhqwEeAEeiBQ-3nrkp-9Q&pVal=320176");
URLConnection uc = url.openConnection();
String userpass = "**" + ":" + "*";
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
uc.setRequestProperty("Authorization", basicAuth);
inputXml = uc.getInputStream();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(inputXml);
NodeList parentNod = doc.getElementsByTagName("results");
List<DBObject> documents = new ArrayList<DBObject>();
if (parentNod.getLength() > 0) {
for (int i = 0; i < parentNod.getLength(); i++) {
DBObject document1 = new BasicDBObject();
Element nodo = (Element) parentNod.item(i);
NodeList nodeList = nodo.getChildNodes();
for (int j = 0; j <= nodeList.getLength(); j++) {
Element childNodo = (Element) nodeList.item(j);
String childTagName = childNodo.getTagName();
String childTextContent = childNodo.getTextContent();
System.out.println("Tag Name: " + childTagName);
System.out.println("Tag Value: " + childTextContent);
document1.put(childTagName, childTextContent);
}
documents.add(document1);
}
System.out.println("" + documents);
}
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
finally {
try {
if (inputXml != null) {
inputXml.close();
}
}
catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
Guess the parsing logic is wrong, not very sure. Any help will be much appreciated.
Thanks