Hi Thilina
Thanks for replying
Here is a piece of the client code
It is a in a unit test case
public class AttachmentsService_ServiceWernerTestCase extends
junit.framework.TestCase {
.......
.......
}
private class StreamListener extends Thread {
private int time;
private ByteArrayOutputStream outputStream;
public StreamListener(int time) {
this.time = time;
}
public void run() {
try {
//Write
DataHandler[] ret =
binding.returnStreamingByteArray(time);
assertNotNull("Expected non-null value to be
returned",ret);
assertEquals("Expected length of DataHandler array to be 1", 1,
ret.length);
//Read
DataHandler handler = ret[0];
InputStream is = handler.getInputStream();
int value;
outputStream = new ByteArrayOutputStream();
try {
while ((value = is.read()) != -1) {
outputStream.write(value);
}
} finally {
outputStream.close();
}
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
public int getNrBytesRead() {
return outputStream == null ? 0 : outputStream.size();
}
public byte[] getBytes() {
return outputStream == null ? new byte[0] :
outputStream.toByteArray();
}
}
public void testAttachmentsServiceReturnStreamingByteArray() throws
Exception {
// Test operation
long start = System.currentTimeMillis();
StreamListener listener = new StreamListener(10000);
listener.start();
int nrOfBytesRead = 0;
int previousNrOfBytesRead = 0;
while (System.currentTimeMillis() < start + 10000) {
Thread.sleep(1000);
nrOfBytesRead = listener.getNrBytesRead();
assertTrue("Expected number of bytes read to have
incremented", nrOfBytesRead > previousNrOfBytesRead);
previousNrOfBytesRead = nrOfBytesRead;
}
listener.join();
byte[] returnedBytes = listener.getBytes();
assertTrue("Expected streaming to have lasted more than 10 seconds",
System.currentTimeMillis() - start > 10000);
assertTrue("Expected byte array to be filled", returnedBytes.length >
0);
}
-----Original Message-----
From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 10, 2007 7:18 AM
To: [email protected]
Subject: Re: Streaming Soap with Attachments
Hi,
Sorry being late to reply... But better late than never :)..
> But what I got is an overhead equivalent to the time spend to transmit
the
> whole file to the client before the streaming begins(my conclusion was
that
> the data is received in a one-go and because of it's large size it
take's
> the processor sometime to allocate some memory space to save it before
the
> streaming even begins).... Does anyone have any explanation? Thanks in
>advance
Are you using Axis2 file caching on the client side.. It would be
great if you can post us your client (receiving) side code..
With Axis2 you also have the ability to directly grab the incoming
stream for your use..
Thanks,
Thilina
--
Thilina Gunarathne - http://www.wso2.com -
http://thilinag.blogspot.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]