facebook

byte[] in webservice

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #289642 Reply

    Ashish Saraf
    Member

    Hello,

    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

    #289652 Reply

    Loyal Water
    Member

    What is the error that is returned?

    #289676 Reply

    Ashish Saraf
    Member

    Hi,
    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

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: byte[] in webservice

You must be logged in to post in the forum log in