Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
sarafashish
Post subject: byte[] in webservice  PostPosted: Oct 02, 2008 - 03:12 PM



Joined: Jul 28, 2008
Posts: 8

Hello,

I have written a webservice method which return byte[] of a pdf file
the code snippet is as follows:
Code:

   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 :
Code:

   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
 
 View user's profile Send private message  
Reply with quote Back to top
support-nipun
Post subject: RE: byte[] in webservice  PostPosted: Oct 02, 2008 - 07:21 PM
Registered Member
Registered Member


Joined: Apr 18, 2007
Posts: 5658

What is the error that is returned?

_________________
Nipun
MyEclipse Support
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
sarafashish
Post subject: RE: byte[] in webservice  PostPosted: Oct 03, 2008 - 09:26 AM



Joined: Jul 28, 2008
Posts: 8

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
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits