users@jax-rpc.java.net

RE: RE: Re: Re: Using DataHandler as return value from a method

From: Tardif, Sebastien <STARDIF_at_anacomp.com>
Date: Tue, 2 Nov 2004 09:01:04 -0500

The approch to be able to do streaming is to use SwA or DIME. When using RPC or document-literal-wrapped style the generated Java code from WSDL should give you DataHandler for parameter type. DataHandler can do streaming. Axis is streaming by creating temporary file so it doesn't take more memory because you transfer big file.

Both DIME and SwA require to write the WSDL by hand if you want the WSDL show the fact that you are using SwA or DIME for transfer of attachment.


-----Original Message-----
From: Karr, David [mailto:david.karr_at_wamu.net]
Sent: Monday, November 01, 2004 4:43 PM
To: users_at_jax-rpc.dev.java.net
Subject: RE: Re: Re: Using DataHandler as return value from a method


Other people may know more about this, but I believe the use of the
DataHandler will only "stream" until it hits the marshal/unmarshal
border. There will be no streaming across the SOAP communications
interface. If I were you, I'd either try to simplify your messages, or
you'll need to build an "out-of-band" communications interface that
allows you to efficiently stream large payloads.

Nevertheless, I'd definitely like to hear about your progress with this.

> -----Original Message-----
> From: Martin Marinschek [mailto:martin.marinschek_at_gmail.com]
>
> The problem is that I might have to stream files with
> gigabyte-sizes, and I cannot increase the memory size
> indefinitely - I am using stream-based writing and reading
> via the datahandler interface, so there should not be much
> memory necessary...
>
> I know that I can increase the JVM memory with the settings
> you are talking about, I just need to make sure that JAX-RPC
> scales to whatever sizes of documents are coming along and
> the document does not have to fit in memory at once.
>
> regards,
>
> Martin
>
>
> On Sun, 31 Oct 2004 08:06:18 -0800, Karr, David
> <david.karr_at_wamu.net> wrote:
> > Wouldn't this be resolved if you just increased the JVM
> memory size?
> > I'm not sure what the defaults are on the platform you're
> using, but
> > you can figure out approximately what it's set to by watching your
> > process listing. If the process size appears to be about
> 256mb, then
> > add "-Xmx384m" to your command line (you might want
> "-Xms384m" also).
> >
> > > -----Original Message-----
> > > From: Martin Marinschek [mailto:generalquestions_at_hotmail.com]
> > >
> > > Hi Vishal,
> > >
> > > this is my command-line (I am starting from Idea):
> > >
> > > C:\java\j2sdk1.4.2_04\bin\java -Didea.launcher.port=7532
> > > -Didea.launcher.library=C:\java\IntelliJ\bin\breakgen.dll
> > > -Dfile.encoding=windows-1252 -classpath
> > > [elided]
> > > com.intellij.rt.execution.application.AppMain
> > > at.oekb.clearinghouse.webservices.client.content.DemoClient
> > >
> > > and I use the jwsdp1.4 files...
> > >
> > > Would it work for you with say a 170MB file as well?
> > >
> > > What I would need to know is if jax-rpc principally scales to any
> > > sizes of documents if streams are used or if some restriction is
> > > built in as
> > > the message is at some point of time put into a byte-array or
> > > something
> > > like that?
> > >
> > > regards,
> > >
> > > Martin
> > >
> > >
> > > Vishal Mahajan wrote:
> > >
> > > > Hi Martin,
> > > >
> > > > I tried reproducing the problem you've reported. I wrote a
> > > small test
> > > > which tries to internalize a soap message containing a (~)17 MB
> > > > XML attachment, gets the DataHandler on the attachment, and
> > > finally prints
> > > > the data as you are trying to do in your client code. The
> > > test passed
> > > > with JDK 1.4.2_04 as well as with JDK 5.0. Can you please
> > > provide more
> > > > information about your environment.
> > > >
> > > > Thanks,
> > > >
> > > > Vishal
> > > >
> > > > Martin Marinschek wrote:
> > > >
> > > >> Hi,
> > > >>
> > > >> would there be no one interested in problems with large
> > > attachments?
> > > >> Are webservices really only useful for small junks of data?
> > > >>
> > > >> regards,
> > > >>
> > > >> Martin
> > > >>
> > > >> >> My original message
> > > >>
> > > >> Hi there,
> > > >>
> > > >> I am using JAX-RPC, and compile my WSDL from the following
> > > interface:
> > > >>
> > > >> public interface ContentServer extends Remote
> > > >> {
> > > >> public DataHandler downloadContent(String userName, String
> > > >> passWord, long id)
> > > >> throws RemoteException;
> > > >> }
> > > >>
> > > >> Now I am filling the return value with the code in the
> respective
> > > >> Impl-class (code of the impl-class can be found further below).
> > > >>
> > > >> Finally, I compile client stubs for the code and run a
> > > small client
> > > >> against those stubs - printing out the retrieved values:
> > > >>
> > > >> public class DemoClient
> > > >> {
> > > >> public static void main (String args[])
> > > >> throws Exception
> > > >> {
> > > >> ContentServer_Service_Impl service =
> > > >> new ContentServer_Service_Impl();
> > > >> ContentServer_PortType stub =
> > > service.getContentServerPort();
> > > >>
> > > >> DataHandler handler =
> > > stub.downloadContent("exmam","xxx",45);
> > > >>
> > > >> BufferedReader instr = new BufferedReader(
> > > >> new
> InputStreamReader(handler.getInputStream()));
> > > >>
> > > >> String str=null;
> > > >>
> > > >> while((str = instr.readLine())!=null)
> > > >> System.out.println(str);
> > > >>
> > > >> System.out.println("success");
> > > >>
> > > >> }
> > > >> }
> > > >>
> > > >> This works fine if the file is a rather small one (let's
> > > say up to a
> > > >> megabyte), with larger files (I tried a 16MB file) I
> > > inevitably run
> > > >> into the following exception, even though my memory should
> > > easily be
> > > >> able to cope with the size of the file and I am using only
> > > >> stream-based access....
> > > >>
> > > >> Are there any restrictions on how large an attached file
> > > can grow in
> > > >> using the JAX-RPC Datahandler mapping?
> > > >>
> > > >> regards,
> > > >>
> > > >> Martin
> > > >>
> > > >> java.lang.OutOfMemoryError
> > > >> 04.10.2004 13:10:55 com.sun.xml.messaging.saaj.soap.MessageImpl
> > > >> <init>
> > > >> SCHWERWIEGEND: SAAJ0535: Unable to internalize message
> > > >> java.rmi.RemoteException: HTTP transport error:
> > > >> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to
> > > >> internalize message; nested exception is:
> > > >> HTTP transport error:
> > > com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> > > >> Unable to internalize message
> > > >> at
> > > >>
> > > at.oekb.clearinghouse.webservices.client.content.ContentServer
> > >
> _PortType_Stub.downloadContent(ContentServer_PortType_Stub.java:89)
> > > >>
> > > >> at
> > > >>
> > >
> at.oekb.clearinghouse.webservices.client.content.DemoClient.main(Dem
> > > o
> > > >> Client.java:27)
> > > >>
> > > >> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > >> at
> > > >>
> > >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl
> > > .
> > > >> java:39)
> > > >>
> > > >> at
> > > >>
> > >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > > s
> > > >> sorImpl.java:25)
> > > >>
> > > >> at java.lang.reflect.Method.invoke(Method.java:324)
> > > >> at
> > > >>
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:7
> > > >> 8)
> > > >> Caused by: HTTP transport error:
> > > >> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to
> > > internalize
> > > >> message
> > > >> at
> > > >>
> > > com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpCli
> > > entTransport.java:140)
> > > >>
> > > >> at
> > > >>
> > >
> com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:92
> > > )
> > > >> at
> > > >>
> > > at.oekb.clearinghouse.webservices.client.content.ContentServer
> > >
> _PortType_Stub.downloadContent(ContentServer_PortType_Stub.java:72)
> > > >>
> > > >> ... 6 more
> > > >> Exception in thread "main"
> > > >>
> > > >> public class ContentServerImpl implements ContentServer {
> > > >> public DataHandler downloadContent(String userName, String
> > > >> passWord, long id)
> > > >> {
> > > >>
> > > >> String dsName1 = "jdbc/roncalli_dev"; // JNDI name
> > > >> javax.sql.DataSource ds1 = null;
> > > >> Connection conn = null;
> > > >>
> > > >> try
> > > >> {
> > > >> Context ic = new InitialContext();
> > > >> Context ctx = (Context) ic.lookup("java:comp/env");
> > > >> ds1 = (javax.sql.DataSource)ctx.lookup(dsName1); //
> > > >> Problem here
> > > >> conn = ds1.getConnection();
> > > >>
> > > >> } catch (Exception e) {
> > > >> e.printStackTrace();
> > > >> }
> > > >>
> > > >>
> > > >> InputStream dataStream =
> > > >> XMLLoader.getAsAsciiStream(conn,"contents","id","data",id);
> > > >> StreamDataSource src = new StreamDataSource();
> > > >> src.setInputStream(dataStream);
> > > >> src.setName("content.xml");
> > > >>
> > > >> DataHandler handler = new DataHandler(src);
> > > >>
> > > >> return handler;
> > > >> }
> > > >>
> > > >> public static class StreamDataSource implements DataSource
> > > >> {
> > > >> private InputStream _inputStream;
> > > >> private OutputStream _outputStream;
> > > >> private String _name;
> > > >> private String _contentType = "text/xml";
> > > >>
> > > >> public void setInputStream(InputStream inputStream)
> > > >> {
> > > >> _inputStream = inputStream;
> > > >> }
> > > >>
> > > >> public void setName(String name)
> > > >> {
> > > >> _name = name;
> > > >> }
> > > >>
> > > >> public void setOutputStream(OutputStream outputStream)
> > > >> {
> > > >> _outputStream = outputStream;
> > > >> }
> > > >>
> > > >> public InputStream getInputStream() throws IOException
> > > >> {
> > > >> return _inputStream;
> > > >> }
> > > >>
> > > >> public OutputStream getOutputStream() throws IOException
> > > >> {
> > > >> return _outputStream;
> > > >> }
> > > >>
> > > >> public String getContentType()
> > > >> {
> > > >> return _contentType;
> > > >> }
> > > >>
> > > >> public String getName()
> > > >> {
> > > >> return _name;
> > > >> }
> > > >>
> > > >> public void setContentType(String contentType)
> > > >> {
> > > >> _contentType = contentType;
> > > >> }
> > > >> }
> > > >> }
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> > For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net