- This topic has 2 replies, 2 voices, and was last updated 16 years, 1 month ago by Ashish Saraf.
-
AuthorPosts
-
Ashish SarafMemberHello,
I have written a webservice method which return byte[] of a pdf file
the code snippet is as follows:public byte[] getStatement(String cardNo, String statementDate) { byte[] returnValue = null; try { Class.forName(formsParameter.getDriver()); con = DriverManager.getConnection(formsParameter.getUrl(), formsParameter.getUsername(), formsParameter.getPassword()); statement = con.createStatement(); ResultSet resultSet = statement .executeQuery("SELECT \"pdfFileName\" ap, \"pdfFileId\", \"cycleId\" ac FROM \"" + formsParameter.getSchema() + "\".\"pdffiles\" WHERE \"accountID\" = '" + cardNo + "' AND \"pdfFileStatementDate\" = TO_DATE('" + statementDate + "', 'YYYY-MM-DD')"); if (resultSet.next()){ File pdfFile = new File(formsParameter.getStatementDrive() + "//" + formsParameter.getStatementRoot() + "//" + formsParameter.getStatementStore() + "//" + resultSet.getInt("ac") + "//" + resultSet.getString("ap")); returnValue = getBytesFromFile(pdfFile); } con.close(); } catch (Exception ex) { ex.printStackTrace(); returnValue = null; } finally { return returnValue; } }
this webservice method when invoded through a java webservice client, displays the pdf file on the web browser code snippet :
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("Content-disposition", "inline; filename=statement.pdf"); ServletOutputStream oOutput = response.getOutputStream(); ABBCCStmtPortTypeProxy aBCCStmtPortTypeProxy = new ABCCStmtPortTypeProxy(); byte[] bytes = abCCStmtPortTypeProxy.getStatement( "4718610100014696", "2008-08-20"); oOutput.write(bytes); }
However when this webservice method is invoked through a .NET application it fails.
Any comment or help on this please
——————————
Regards,
Ashish Saraf
Loyal WaterMemberWhat is the error that is returned?
Ashish SarafMemberHi,
When the file is saved using .net webservice client the resultant file does not open in pdf reader. However the same is done using java webservice client the file is saved as pdf and it opens up in pdf reader. Does java and .net interprete byte[] differently? or is there any other return type which will be compatible in both java and .net?Regards,
Ashish Saraf
-
AuthorPosts