Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Stream from vb.net Webservice to java client

Reply
Thread Tools

Stream from vb.net Webservice to java client

 
 
Filipe Marcelino
Guest
Posts: n/a
 
      08-03-2007
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

 
Reply With Quote
 
 
 
 
Filipe Marcelino
Guest
Posts: n/a
 
      08-03-2007
On 3 ago, 11:14, Filipe Marcelino <(E-Mail Removed)> 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.FileOutpu tStream("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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM
WebService on Java server versus WebService on .NET Mr. x Java 2 10-09-2003 11:21 PM



Advertisments