I am trying to connect my java application with SSRS 2008 R2 using the URL access method .Servlets in my application connect to SSRS reports.
I am forming http urls in the servlets and trying to connect to report server but i am geting 401 unauthorised for URL
I am passing a userid and password from the java application.below is the code for Servlet
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String urlString = "http://mydev/ReportServer/Pages/ReportViewer.aspx?"
+"/Test&rs:Command=Render&county="+ new Integer(1)
System.out.println("The url string is"+urlString);
URL url = new URL(urlString);
HttpURLConnection repCon = (HttpURLConnection)url.openConnection();
repCon.setRequestProperty("Content-type", "application/pdf" );
System.out.println("the response code"+repCon.getResponseCode());
// Send parameter string to report server
PrintWriter repOutStream = new PrintWriter(repCon.getOutputStream());
I get response code 401 .Its not able to connect to the url
If i type the same url in the browser i am able to get the reports but from the Java application it gives 401 error.
What could be the possible reason.Is it that Weblogic on which my java application is deployed is not able to talk to SSRS or some configuration missing on ssrs end ?
Please help. I have been working on This for days now with no result.The network admin says that SSRS configurations are correct though I am not sure of it.
I believe what you are trying to achieve is not possible and it is failing with Authentication.
You might need to try WebService API and we have a code sample for C# here, which you can use for reference to make modification:
Thanks for your reply. Is there a reason why the above code which i am using is not possible.Its a simple Java servlet code which connects to a url and brings back the response.This is one of the sample code i found which is used to connect from Java to SSRS
I tried the web service approach before and used weblogic(the webserver I am using for Java) tool clientgen to generate the client stubs for the wsdl file and it was giving n numbers of errors for missing jar files not on compilation but when I was trying to run the code.Though I included almost every jar file possible
Can anyone suggest any document or reference I can use to generate the client stub and necessary libraries needed when generating client code from SSRS wsdl for Java
I have not found any latest article on internet which says how we can connect SSRS with Java using webservice approach with example.
Does microsoft provides any document for java users to connect to SSRS everywhere it is .NET examples.
Also Fanny - Could anyone suggest a solution for this?
Thanks everyone for helping!
Usually 401 Error occurs when the authentication is not attached to the request sent. Now the method you are using may not be a reliable way to pass the request. So that is why we recommend using Web service API.
You can refer the below blog to build the solution based on the information and code sample provided, which uses Web Service API. Hope this should help you in getting a solution built.
Accessing MS Reporting Services with Java
However this also covers the max boundary we can cover on this forum request as we don't have a readymade solution or document available.