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
{
try
{
Authenticator.setDefault(new ReportAuthenticator("domain\\username","password"));
String urlString = "http://mydev/ReportServer/Pages/ReportViewer.aspx?"
+"/Test&rs:Command=Render&county="+ new Integer(1)
+ "&rs:format=pdf";
System.out.println("The url string is"+urlString);
URL url = new URL(urlString);
HttpURLConnection repCon = (HttpURLConnection)url.openConnection();
repCon.setRequestMethod("POST");
repCon.setDoOutput(true);
repCon.setUseCaches(false);
repCon.setFollowRedirects(false);
repCon.setRequestProperty("User-Agent", "Mozilla/5.0");
repCon.setRequestProperty("Content-type", "application/pdf" );
repCon.setRequestProperty("Content-length", Integer.toString(parameterString.length()));
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.
Thanks,