473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

streaming soap with attachments

7
dear all
this might be a piece of cake for some of you out there but it is causing me a lot of stress given the fact that there is not enogh documentation out there regarding this topic

I am writing a web service that uses soap with attachments to send a large streaming data,
The concept works quite well but when I started to test it I got this problem.
When my client program calls a method that should return a real time data the streaming starts after 10 seconds
How can I avoid the fact that the message calls waits that long before the data starts streaming in?
To be more specific
I have a method that returns a streaming data in 10 seconds [getSteamingData(long seconds)]
I would like to test if I already get some data steaming in after one second of it starts.
To do so I started a thread that checks the OutputSteam size every 1 second and then compare the result with the previous size say a second ago, there should be an increase in size each second!!!
But when I start the thread… the streaming does not start right away instead, it starts after 10 seconds causing the thread to return null size
In real life with real large streaming data that 10 seconds could be 10 hours or God forbidden 10 years
Is there a way around or is that not possible in SwA?
Anybody have any idea
thanks in advance
Jun 28 '07 #1
5 3523
r035198x
13,262 8TB
dear all
this might be a piece of cake for some of you out there but it is causing me a lot of stress given the fact that there is not enogh documentation out there regarding this topic

I am writing a web service that uses soap with attachments to send a large streaming data,
The concept works quite well but when I started to test it I got this problem.
When my client program calls a method that should return a real time data the streaming starts after 10 seconds
How can I avoid the fact that the message calls waits that long before the data starts streaming in?
To be more specific
I have a method that returns a streaming data in 10 seconds [getSteamingData(long seconds)]
I would like to test if I already get some data steaming in after one second of it starts.
To do so I started a thread that checks the OutputSteam size every 1 second and then compare the result with the previous size say a second ago, there should be an increase in size each second!!!
But when I start the thread… the streaming does not start right away instead, it starts after 10 seconds causing the thread to return null size
In real life with real large streaming data that 10 seconds could be 10 hours or God forbidden 10 years
Is there a way around or is that not possible in SwA?
Anybody have any idea
thanks in advance
Unfortunately once things over a network cable lots of things come into into play. It could be just your network playing tricks e.t.c. I don't know if posting your method for sending the data will help.
Jun 28 '07 #2
pmakoi
7
thxs for the quick reply
here is the code

Expand|Select|Wrap|Line Numbers
  1.  public javax.activation.DataHandler[] returnStreamingByteArray(final int timeout) {
  2.         DataHandler ret = new DataHandler(new DataSource() {
  3.             private long start = System.currentTimeMillis();
  4.             private long end = start + timeout;
  5.  
  6.             public String getContentType() {
  7.                 return "text/plain";
  8.             }
  9.  
  10.             public InputStream getInputStream() throws IOException {
  11.                 return new InputStream() {
  12.                     public int read() throws IOException {
  13.                         try {
  14.                             Thread.sleep(10);
  15.                         } catch (InterruptedException e) {
  16.                             //ignore this exception
  17.                         }
  18.                         if (System.currentTimeMillis() > end) {
  19.                             return -1;
  20.                         } else {
  21.                             return (int)(Math.random() *  256);
  22.                         }
  23.                     }
  24.                 };
  25.             }
  26.  
  27.             public String getName() {
  28.                 return "";
  29.             }
  30.  
  31.             public OutputStream getOutputStream() throws IOException {
  32.                 return null;
  33.             }
  34.  
  35.         });
  36.         return new DataHandler[]{ret};
  37.     }
Jun 28 '07 #3
r035198x
13,262 8TB
thxs for the quick reply
here is the code

Expand|Select|Wrap|Line Numbers
  1.  public javax.activation.DataHandler[] returnStreamingByteArray(final int timeout) {
  2.         DataHandler ret = new DataHandler(new DataSource() {
  3.             private long start = System.currentTimeMillis();
  4.             private long end = start + timeout;
  5.  
  6.             public String getContentType() {
  7.                 return "text/plain";
  8.             }
  9.  
  10.             public InputStream getInputStream() throws IOException {
  11.                 return new InputStream() {
  12.                     public int read() throws IOException {
  13.                         try {
  14.                             Thread.sleep(10);
  15.                         } catch (InterruptedException e) {
  16.                             //ignore this exception
  17.                         }
  18.                         if (System.currentTimeMillis() > end) {
  19.                             return -1;
  20.                         } else {
  21.                             return (int)(Math.random() *  256);
  22.                         }
  23.                     }
  24.                 };
  25.             }
  26.  
  27.             public String getName() {
  28.                 return "";
  29.             }
  30.  
  31.             public OutputStream getOutputStream() throws IOException {
  32.                 return null;
  33.             }
  34.  
  35.         });
  36.         return new DataHandler[]{ret};
  37.     }
What value are you passing for the timeout?
Jun 28 '07 #4
pmakoi
7
the value that i gave it is 10000

here is a part of a unit test class that i used to test it

Expand|Select|Wrap|Line Numbers
  1.  package com.markit.soapattachments.client;
  2.  
  3. import javax.activation.DataHandler;
  4. import java.io.InputStream;
  5. import java.io.ByteArrayOutputStream;
  6. import java.util.Arrays;
  7.  
  8. public class AttachmentsService_ServiceWernerTestCase extends junit.framework.TestCase {
  9.  
  10. ……………………………………
  11. …………………………………
  12.  
  13.  
  14.  
  15. //this is the thread that runs the test
  16.     private class StreamListener extends Thread {
  17.  
  18.         private int time;
  19.         private ByteArrayOutputStream outputStream;
  20.  
  21.         public StreamListener(int time) {
  22.             this.time = time;
  23.         }
  24.  
  25.         public void run() {
  26.             try {
  27.                 //Write
  28.                 DataHandler[] ret = binding.returnStreamingByteArray(time);
  29.  
  30. assertNotNull("Expected non-null value to be returned",ret);
  31. assertEquals("Expected length of DataHandler array to be 1", 1, ret.length);
  32.  
  33.                 //Read
  34.                 DataHandler handler = ret[0];
  35.  
  36.                 InputStream is = handler.getInputStream();
  37.                 int value;
  38.                 outputStream = new ByteArrayOutputStream();
  39.                 try {
  40.                     while ((value = is.read()) != -1) {
  41.                         outputStream.write(value);
  42.                     }
  43.                 } finally {
  44.                     outputStream.close();
  45.                 }
  46.             } catch (Exception e) {
  47.                 fail("Unexpected exception: " + e);
  48.             }
  49.         }
  50.  
  51.         public int getNrBytesRead() {
  52.             return outputStream == null ? 0 : outputStream.size();
  53.         }
  54.  
  55.         public byte[] getBytes() {
  56.             return outputStream == null ? new byte[0] : outputStream.toByteArray();
  57.         }
  58.     }
  59.  
  60.     public void testAttachmentsServiceReturnStreamingByteArray() throws Exception {
  61.         // Test operation
  62.         long start = System.currentTimeMillis();
  63.  
  64.         StreamListener listener = new StreamListener(10000);
  65.         listener.start();
  66.         int nrOfBytesRead = 0;
  67.         int previousNrOfBytesRead = 0;
  68.  
  69.         while (System.currentTimeMillis() < start + 10000) {
  70.             Thread.sleep(1000);
  71.             nrOfBytesRead = listener.getNrBytesRead();
  72.             assertTrue("Expected number of bytes read to have incremented", nrOfBytesRead > previousNrOfBytesRead);
  73.             previousNrOfBytesRead = nrOfBytesRead;
  74.         }
  75.         listener.join();
  76.  
  77.         byte[] returnedBytes = listener.getBytes();
  78.  
  79.         assertTrue("Expected streaming to have lasted more than 10 seconds", System.currentTimeMillis() - start > 10000);
  80.  
  81.         assertTrue("Expected byte array to be filled", returnedBytes.length > 0);
  82.  
  83.     }
  84.  
  85.  
  86. }
Jun 29 '07 #5
pmakoi
7
first i would like to thank every viewer for their attention and r035198x in particular

I have been goggling around trying to figure out what might have been going wrong during the transmission? And I came up with some questions that might provide a hint as to where the problems might be coming from?
1- in old postings about SwA it is stated that the attachments are sent in a one-go fashion, is that still the case now or can some new implementations support streaming the attachments through the network?
If there are no data streaming soap with attachments implementations out there, would my problem be, that the streaming that I am trying to simulate in the above code is just using the activations framework streaming capabilities and the 10000 ms overhead is just a result of the work done by the processor to allocate resources for the large amount of data that is being received in one-go?
Jul 4 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: jangolan | last post by:
Hi, I have written an application in C++ that consumes webservices. The application works great on my pc, which I have visual studio installed. When I deploy the application to other user's pcs,...
3
by: Ipsita | last post by:
Hi! I am trying SOAP with DIME attachments in web services. For example say, I have a file resume.pdf stored somewhere on my server. How does the web service send the file to the client, so that...
1
by: SqlJunkies User | last post by:
Hi! is there any way to to upload a file as a soap-attachment??? I have written a jscript function that handles all form-data, packs it up into one xml-file and sends it off to the server....
0
by: saliwen | last post by:
Can WSE2.0 implements SOAP Attachments of W3C for interoperations ?
3
by: flo | last post by:
hi, i have to develop a web service client (must be .net, currently i'm using c# with wse3) for a java service. the java service uses mime attachments for up- and download of files. i googled...
6
by: Brybot | last post by:
I am trying to allow HTTP POST file uploads to my web service. Currently I have it working perfectly for a SOAP/XML request reading in a byte using MemoryStream/FileStream but I cannot figure out...
1
by: addisonp | last post by:
Problem: How to have a php web service return the soap output message in a data stream, where one node is sent at a time to the client. This is due to sending a large amount of database information...
0
by: xanax13 | last post by:
Hi, I'm trying to use python as a client for a Java (Axis) web service that handle attachments (files) No problem with a java client, but i don't know how to do with python. I tried ZSI but i...
0
by: =?Utf-8?B?SGVscCBOZWVkZWQ=?= | last post by:
Hi, I am sending mail attachments thru SOAP. I am using "RequestSoapContext.Attachments.Add"; everything is working fine, but How can I set the FileName for the attachments. When I set my file...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.