Stream from vb.net Webservice to java client

Discussion in 'ASP .Net Web Services' started by Filipe Marcelino, Aug 3, 2007.

  1. hi,

    i have a webservice written in vb.net with this method:

    <WebMethod()> _
    Public Function GetBinaryFile() As Byte()
    'Open a file stream.
    Dim pobjFileStream As System.IO.FileStream = New
    System.IO.FileStream("C:\Inetpub\wwwroot
    \WebService1\DPackSetup2003.exe", IO.FileMode.Open)
    'Allocate a byte array that will hold the contents.
    Dim pbytBytes As Byte() = New Byte(pobjFileStream.Length - 1)
    {}
    'Now read the stream.
    pobjFileStream.Read(pbytBytes, 0, pobjFileStream.Length)
    'Now convert to a base64 string and return.
    Return pbytBytes
    End Function

    What this method does is to return a byte array with the contents of
    the file. What i want to do is to have a java client that will get
    this byte array and write it to disk. I came up with the following
    method:

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt)
    {
    // TODO add your handling code here:


    try { // Call Web Service Operation
    javawebservice_dotnet_axis.Service1 service = new
    javawebservice_dotnet_axis.Service1();
    javawebservice_dotnet_axis.Service1Soap port =
    service.getService1Soap();
    // TODO process result here
    javawebservice_dotnet_axis.Stream result =
    port.getBinaryFile();

    //Grava ficheiro
    java.io_OutputStreamWriter aux = new
    java.io_OutputStreamWriter(new java.io.FileOutputStream("C:\\Documents
    and Settings\\me\\Desktop\\savedStream.exe") );
    aux.write(result.toString());
    aux.flush();
    aux.close();


    } catch (Exception ex) {
    // TODO handle custom exceptions here
    }
    }

    Theorically i should serialize the result to disk but when the program
    reaches the code line 'javawebservice_dotnet_axis.Stream result =
    port.getBinaryFile();', it automatically jumps to the end of the
    method whitout throwing any kind of exception.

    Can someone help me on this?

    Thanks in advance for your attention,
    Marcelino
     
    Filipe Marcelino, Aug 3, 2007
    #1
    1. Advertisements

  2. On 3 ago, 11:14, Filipe Marcelino <> wrote:
    > hi,
    >
    > i have a webservice written in vb.net with this method:
    >
    > <WebMethod()> _
    > Public Function GetBinaryFile() As Byte()
    > 'Open a file stream.
    > Dim pobjFileStream As System.IO.FileStream = New
    > System.IO.FileStream("C:\Inetpub\wwwroot
    > \WebService1\DPackSetup2003.exe", IO.FileMode.Open)
    > 'Allocate a byte array that will hold the contents.
    > Dim pbytBytes As Byte() = New Byte(pobjFileStream.Length - 1)
    > {}
    > 'Now read the stream.
    > pobjFileStream.Read(pbytBytes, 0, pobjFileStream.Length)
    > 'Now convert to a base64 string and return.
    > Return pbytBytes
    > End Function
    >
    > What this method does is to return a byte array with the contents of
    > the file. What i want to do is to have ajavaclientthat will get
    > this byte array and write it to disk. I came up with the following
    > method:
    >
    > private void jButton3MouseClicked(java.awt.event.MouseEvent evt)
    > {
    > // TODO add your handling code here:
    >
    > try { // Call Web Service Operation
    > javawebservice_dotnet_axis.Service1 service = new
    > javawebservice_dotnet_axis.Service1();
    > javawebservice_dotnet_axis.Service1Soap port =
    > service.getService1Soap();
    > // TODO process result here
    > javawebservice_dotnet_axis.Stream result =
    > port.getBinaryFile();
    >
    > //Grava ficheiro
    > java.io_OutputStreamWriter aux = newjava.io_OutputStreamWriter(newjava.io.FileOutputStream("C:\\Documents
    > and Settings\\me\\Desktop\\savedStream.exe") );
    > aux.write(result.toString());
    > aux.flush();
    > aux.close();
    >
    > } catch (Exception ex) {
    > // TODO handle custom exceptions here
    > }
    > }
    >
    > Theorically i should serialize the result to disk but when the program
    > reaches the code line 'javawebservice_dotnet_axis.Stream result =
    > port.getBinaryFile();', it automatically jumps to the end of the
    > method whitout throwing any kind of exception.
    >
    > Can someone help me on this?
    >
    > Thanks in advance for your attention,
    > Marcelino


    I already found out what was happening. Apparently the wsdl file from
    the webservice wasn't updated. After updating the file, all run great.

    Thanks anyway.
     
    Filipe Marcelino, Aug 3, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samuel
    Replies:
    0
    Views:
    671
    Samuel
    Jul 30, 2003
  2. Mr. x
    Replies:
    2
    Views:
    859
    Andrew
    Oct 10, 2003
  3. F Stifter
    Replies:
    0
    Views:
    1,257
    F Stifter
    Nov 30, 2005
  4. Filipe Marcelino
    Replies:
    5
    Views:
    1,880
    Ian Wilson
    Aug 9, 2007
  5. narasimham
    Replies:
    3
    Views:
    313
    narasimham
    Nov 20, 2003
  6. narasimham
    Replies:
    0
    Views:
    250
    narasimham
    Nov 20, 2003
  7. pallavi

    .Net webservice and java client little endian/big endian

    pallavi, Apr 5, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    386
    pallavi
    Apr 5, 2004
  8. Senthil Kumar S

    Accesing .NET webservice using java client

    Senthil Kumar S, Nov 23, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    211
    Dan Rogers
    Nov 23, 2004
Loading...