You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Barry White <ba...@thisbloke.com> on 2003/08/06 10:41:55 UTC

upload progress (bytes sent)

Hi,

I've built a web services client with Apache SOAP 2.3.1 which is used for 
uploading images. I would like to be able to track the number of bytes sent 
for a progress bar but have not found a way of doing this. It is a 
university project so I am still quite new to Java and SOAP.

I have looked through the classes and some of the sources too and have 
found no clues, or just got lost! I guess I need access to the output 
stream. Can anyone tell me if this is possible (it's always possible!) and 
if so maybe give me some pointers.

Thanks in advance,

Barry



Re: upload progress (bytes sent)

Posted by Daniel Zhang <zh...@clinicaltools.com>.
The nightly build of SOAP package has that method, the old versions do 
not. So if you want to use it, you have to download the nightly build.

-Daniel
Barry White wrote:

> Thanks Scott and Daniel,
>
> I am sending the images one SOAP message at a time. The web service 
> can handle an array of images but I have found the client 
> implementation a whole lot easier (error handling, etc.) sending one 
> at a time.
>
> I think it will make tracking upload progress a lot easier too. By 
> modifying HTTPUtils as Scott suggested I can count the payload bytes 
> sent and track progress that way, it doesn't look to difficult.
>
> Daniel: I did a quick search and saw a reference to 
> SOAPHTTPConnection.getRequestCopy(), but there's no such method in the 
> version I'm using.
>
> Barry
>



Re: upload progress (bytes sent)

Posted by Barry White <ba...@thisbloke.com>.
Thanks Scott and Daniel,

I am sending the images one SOAP message at a time. The web service can 
handle an array of images but I have found the client implementation a 
whole lot easier (error handling, etc.) sending one at a time.

I think it will make tracking upload progress a lot easier too. By 
modifying HTTPUtils as Scott suggested I can count the payload bytes sent 
and track progress that way, it doesn't look to difficult.

Daniel: I did a quick search and saw a reference to 
SOAPHTTPConnection.getRequestCopy(), but there's no such method in the 
version I'm using.

Barry

At 13:01 06/08/2003, you wrote:
>Are you tracking the image size uploaded or the whole xml stream? If it's 
>the image size, you can simply sum up the image sizes  uploaded; if it's 
>the xml stream, you can
>call getRequestCopy() to track the bytes. Hope this helps.
>
>-Daniel
>Barry White wrote:
>
>>Hi,
>>
>>I've built a web services client with Apache SOAP 2.3.1 which is used for 
>>uploading images. I would like to be able to track the number of bytes 
>>sent for a progress bar but have not found a way of doing this. It is a 
>>university project so I am still quite new to Java and SOAP.
>>
>>I have looked through the classes and some of the sources too and have 
>>found no clues, or just got lost! I guess I need access to the output 
>>stream. Can anyone tell me if this is possible (it's always possible!) 
>>and if so maybe give me some pointers.
>>
>>Thanks in advance,
>>
>>Barry
>
>
>



Re: Upload multiple files

Posted by Scott Nichol <sn...@scottnichol.com>.
It should be legal.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Daniel Zhang" <zh...@clinicaltools.com>
To: <so...@ws.apache.org>
Sent: Wednesday, August 06, 2003 8:29 AM
Subject: Upload multiple files


> Scott -
> 
> This question comes after Barry White's upload question. If I have 
> multiple files uploaded, one way is to send each file uploaded with 
> seperate soap request, but I don't think it's efficient. So the other 
> way I think, is to create a Datahandler array, then you send all files 
> in this array with single soap request, I think this is more efficient.
> 
> ...
> DataHandler[] dhArray = new DataHandler[fileNumber];
> for (int i = 0; i < fileNumber; i++) {
>     dhArray[i] = new DataHandler(datasource[i]);
> }
> ...
> params.addElement(new Parameter("uploadfiles", 
> javax.activation.DataHandler[].class, dhArray, null));
> ...
> 
> The key point here is "javax.activation.DataHandler[].class" legal or 
> illiegal for class type? Or we have to do extra effort here?
> 
> TIA,
> 
> -Daniel
> 
> 
> 
> 

Upload multiple files

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Scott -

This question comes after Barry White's upload question. If I have 
multiple files uploaded, one way is to send each file uploaded with 
seperate soap request, but I don't think it's efficient. So the other 
way I think, is to create a Datahandler array, then you send all files 
in this array with single soap request, I think this is more efficient.

...
DataHandler[] dhArray = new DataHandler[fileNumber];
for (int i = 0; i < fileNumber; i++) {
    dhArray[i] = new DataHandler(datasource[i]);
}
...
params.addElement(new Parameter("uploadfiles", 
javax.activation.DataHandler[].class, dhArray, null));
...

The key point here is "javax.activation.DataHandler[].class" legal or 
illiegal for class type? Or we have to do extra effort here?

TIA,

-Daniel




Re: upload progress (bytes sent)

Posted by Scott Nichol <sn...@scottnichol.com>.
Barry,

The data is actually written and read in org.apache.soap.util.net.HTTPUtils#post.  You will find that the outoging data is written to the stream in just two buffers, one containing the HTTP request and HTTP headers, and the other containing the full payload.  You would need to change this code to write data in chunks in a loop and call some method to update the status.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Barry White" <ba...@thisbloke.com>
To: <so...@ws.apache.org>
Sent: Wednesday, August 06, 2003 4:41 AM
Subject: upload progress (bytes sent)


> Hi,
> 
> I've built a web services client with Apache SOAP 2.3.1 which is used for 
> uploading images. I would like to be able to track the number of bytes sent 
> for a progress bar but have not found a way of doing this. It is a 
> university project so I am still quite new to Java and SOAP.
> 
> I have looked through the classes and some of the sources too and have 
> found no clues, or just got lost! I guess I need access to the output 
> stream. Can anyone tell me if this is possible (it's always possible!) and 
> if so maybe give me some pointers.
> 
> Thanks in advance,
> 
> Barry
> 
> 
> 

Re: upload progress (bytes sent)

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Are you tracking the image size uploaded or the whole xml stream? If 
it's the image size, you can simply sum up the image sizes  uploaded; if 
it's the xml stream, you can
call getRequestCopy() to track the bytes. Hope this helps.

-Daniel
Barry White wrote:

> Hi,
>
> I've built a web services client with Apache SOAP 2.3.1 which is used 
> for uploading images. I would like to be able to track the number of 
> bytes sent for a progress bar but have not found a way of doing this. 
> It is a university project so I am still quite new to Java and SOAP.
>
> I have looked through the classes and some of the sources too and have 
> found no clues, or just got lost! I guess I need access to the output 
> stream. Can anyone tell me if this is possible (it's always possible!) 
> and if so maybe give me some pointers.
>
> Thanks in advance,
>
> Barry
>