Hi all-
I have a .NET web service that returns a file in the form of an array of bytes. I'm wanting to write that into a file on the client's machine, but i've been unable to do so. I mean, I can print the array of bytes to a file, but its not converted back to the format it was originally in. The following is my service code:
The following is what I have for my perl script so far:
Any suggestions for handling this array of bytes?
Thank you.
James Johnston
I have a .NET web service that returns a file in the form of an array of bytes. I'm wanting to write that into a file on the client's machine, but i've been unable to do so. I mean, I can print the array of bytes to a file, but its not converted back to the format it was originally in. The following is my service code:
Code:
[WebMethod]
public byte[] DownloadFile(string FName)
{
System.IO.FileStream fs1 = null;
fs1 = System.IO.File.Open(FName, FileMode.Open, FileAccess.Read);
byte[] b1 = new byte[fs1.Length];
fs1.Read(b1, 0, (int)fs1.Length);
fs1.Close();
return b1;
}
Code:
use SOAP::Lite;
open FILE, '>boot.ini' or die $!;
#binmode FILE;
my $soap = SOAP::Lite
-> uri('http://tempuri.org')
-> on_action( sub { join '/', 'http://tempuri.org', $_[1] } )
-> proxy('http://localhost:1982/FileDownload.asmx');
my $method = SOAP::Data->name('DownloadFile')
->attr({xmlns => 'http://tempuri.org/'});
my @params = ( SOAP::Data->name(FName => 'c:\boot.ini') );
$temp = $soap->call($method => @params)->result;
#binmode $temp;
print FILE $temp;
close(FILE);
Thank you.
James Johnston