Can a web service return a file?

Discussion in 'ASP .Net Web Services' started by Uzi, Jun 23, 2006.

  1. Uzi

    Uzi Guest

    Hi all,

    My web service does some work on a remote machine. A file is created on
    the remote machine as a result of this work.
    How do I return this file to the web service client on the local
    machine?

    Thaks,

    Uzi
    Uzi, Jun 23, 2006
    #1
    1. Advertising

  2. Uzi

    Josh Twist Guest

    Josh Twist, Jun 23, 2006
    #2
    1. Advertising

  3. You can do this simpeler and platform independent

    take the file as a binary stream , now encodebase64 this stream ( you gat
    a string in return )

    now pass this string to the other side , on the other side you can perform a
    decodebas64 on the string and output it to a file

    this way you can send anything you want over the wire ( executables , word
    documents etc etc etc )

    In my reallife situation i created a custom XML with a filename tag , a
    description tag and a data tag ( the one containing the enocoded data )
    this way the receiver does not have to guess the file name or type


    regards

    Michel Posseth [MCP]


    "Josh Twist" <> schreef in bericht
    news:...
    > Hi Uzi,
    >
    > You could read all bytes and return it as a byte[] array or you could
    > look at MTOM provided by MS in Web Service Extensions 3.0.
    >
    > http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx
    >
    > Josh
    > http://www.thejoyofcode.com/
    >
    > Uzi wrote:
    >> Hi all,
    >>
    >> My web service does some work on a remote machine. A file is created on
    >> the remote machine as a result of this work.
    >> How do I return this file to the web service client on the local
    >> machine?
    >>
    >> Thaks,
    >>
    >> Uzi

    >
    Michel Posseth [MCP], Jun 24, 2006
    #3
  4. Uzi

    Josh Twist Guest

    ASP.NET Web Services automatically serialise byte[] into base64 - so
    there's no need to do it yourself.

    Josh
    http://www.thejoyofcode.com/


    Michel Posseth [MCP] wrote:
    > You can do this simpeler and platform independent
    >
    > take the file as a binary stream , now encodebase64 this stream ( you gat
    > a string in return )
    >
    > now pass this string to the other side , on the other side you can perform a
    > decodebas64 on the string and output it to a file
    >
    > this way you can send anything you want over the wire ( executables , word
    > documents etc etc etc )
    >
    > In my reallife situation i created a custom XML with a filename tag , a
    > description tag and a data tag ( the one containing the enocoded data )
    > this way the receiver does not have to guess the file name or type
    >
    >
    > regards
    >
    > Michel Posseth [MCP]
    >
    >
    > "Josh Twist" <> schreef in bericht
    > news:...
    > > Hi Uzi,
    > >
    > > You could read all bytes and return it as a byte[] array or you could
    > > look at MTOM provided by MS in Web Service Extensions 3.0.
    > >
    > > http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx
    > >
    > > Josh
    > > http://www.thejoyofcode.com/
    > >
    > > Uzi wrote:
    > >> Hi all,
    > >>
    > >> My web service does some work on a remote machine. A file is created on
    > >> the remote machine as a result of this work.
    > >> How do I return this file to the web service client on the local
    > >> machine?
    > >>
    > >> Thaks,
    > >>
    > >> Uzi

    > >
    Josh Twist, Jun 24, 2006
    #4
  5. I did know that between .Net and .Net you can send byte data ( and then
    ofcourse it must be represented in some form of string format in the
    transmission )

    However i wrote this service first with the 2002 version ( don`t know if it
    did work with this version to )
    also an advantage i have now is that i send this in a custom XML file where
    i can tell to the client what the enclosing data represents
    and the fact that i exchange this data with clients written in Delphi and
    progress ( unix )

    Michel



    "Josh Twist" <> schreef in bericht
    news:...
    > ASP.NET Web Services automatically serialise byte[] into base64 - so
    > there's no need to do it yourself.
    >
    > Josh
    > http://www.thejoyofcode.com/
    >
    >
    > Michel Posseth [MCP] wrote:
    >> You can do this simpeler and platform independent
    >>
    >> take the file as a binary stream , now encodebase64 this stream ( you
    >> gat
    >> a string in return )
    >>
    >> now pass this string to the other side , on the other side you can
    >> perform a
    >> decodebas64 on the string and output it to a file
    >>
    >> this way you can send anything you want over the wire ( executables ,
    >> word
    >> documents etc etc etc )
    >>
    >> In my reallife situation i created a custom XML with a filename tag , a
    >> description tag and a data tag ( the one containing the enocoded data )
    >> this way the receiver does not have to guess the file name or type
    >>
    >>
    >> regards
    >>
    >> Michel Posseth [MCP]
    >>
    >>
    >> "Josh Twist" <> schreef in bericht
    >> news:...
    >> > Hi Uzi,
    >> >
    >> > You could read all bytes and return it as a byte[] array or you could
    >> > look at MTOM provided by MS in Web Service Extensions 3.0.
    >> >
    >> > http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx
    >> >
    >> > Josh
    >> > http://www.thejoyofcode.com/
    >> >
    >> > Uzi wrote:
    >> >> Hi all,
    >> >>
    >> >> My web service does some work on a remote machine. A file is created
    >> >> on
    >> >> the remote machine as a result of this work.
    >> >> How do I return this file to the web service client on the local
    >> >> machine?
    >> >>
    >> >> Thaks,
    >> >>
    >> >> Uzi
    >> >

    >
    Michel Posseth [MCP], Jun 25, 2006
    #5
    1. Advertising

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. Bharat
    Replies:
    2
    Views:
    1,495
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Sep 5, 2006
  2. Greenhorn
    Replies:
    15
    Views:
    794
    Keith Thompson
    Mar 6, 2005
  3. Replies:
    9
    Views:
    1,722
    Dave Miller
    Jun 18, 2008
  4. DonaldN
    Replies:
    1
    Views:
    523
    Josh Twist
    Feb 17, 2006
  5. Leo Violette
    Replies:
    0
    Views:
    998
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page