See the deprecated MTOMSample.It is not in the dist.. You will need to check out from svn.. I'm not sure whether it is in working condition... But a little bit of tweaking would make it work... http://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/samples/deprecated/mtomsample
I'm hoping to do little bit of testing on attachment streaming if I managed to find some time.. thanks, Thilina On 7/10/07, Peter Makoi <[EMAIL PROTECTED]> wrote:
Hi This approach is quite new to me, so if you could provide an example code I would be very grateful I have always preferred the lazy way of generating client stubs from a wsdl file thanks -----Original Message----- From: Thilina Gunarathne [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 10, 2007 2:26 PM To: [email protected] Subject: Re: Streaming Soap with Attachments Hi, IIRC calling getDataHandler makes Axis2 to read the whole MIME part corresponding to that DataHandler.. Axis2 MIME parser is a lazy parser which reads the MIME parts only when needed..It'll read only till the end of the requested MIME part, but accessing it will cause Axis2 read the whole message if the requested MIME part is the last part of a multipart message. I think the culprit for the time delay you are seeing is the time which Axis2 takes to read the content of the MIME part.. IMHO you won't be able to do streaming using the above logic. But you can dig in to a bit deeper level and use the MessageContext.getIncomingAttachmentStreams() to access the underlying raw data streams of the message.. Please make sure to test the getIncomingAttachmentStreams() a bit before use, as it's one of the least tested parts in Axis2.. Your scenario seems to use MTOM, but "Accessing the MessageContext" sub topic in Using SwA with Axis2[1] article would help you to figure out how to access the message context for a response message.. Also looks like you are using databinding in the client side... Which data binding mechanism are you using... I'm not sure whether you can use the getIncomingAttachmentStreams() together with DataBinding.. I would recommend you to try out the above using a RawXMLClient...[2] Thanks, Thilina [1] http://wso2.org/library/1148 [2] http://ws.apache.org/axis2/1_2/dii.html On 7/10/07, Peter Makoi <[EMAIL PROTECTED]> wrote: > 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] > > -- 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]
-- Thilina Gunarathne - http://www.wso2.com - http://thilinag.blogspot.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
