Hi,

Try add this function to MTOM exmaple that is shipped with XFire

public DataHandler echoData(DataHandler handler)
     {

     try
       {
       System.out.println(handler.getContent().toString());

       }
     catch (IOException e)
       {
       e.printStackTrace();
       }

     return handler;
     }

Add it to interface too.

Client side code :

File file = new File("c:\\temp\\pic1.png");

       DataSource fileSource = new FileDataSource(file);

       DataHandler dataHandlerResult2 = service.echoData(new
DataHandler(fileSource));

       fileSource = dataHandlerResult2.getDataSource();

       try
         {
         InputStream in = fileSource.getInputStream();

         File outputFile = new File("c:\\temp\\outputpic1.png");

         OutputStream out = new BufferedOutputStream(new
FileOutputStream(outputFile));

         byte[] buffer = new byte[2048];

         int len;
         while ((len = in.read(buffer)) > 0) {
             out.write(buffer, 0, len);
         }

         in.close();
         out.flush();
         out.close();

         System.out.println("file saved.");

         }
       catch ( IOException e1 )
         {
         // TODO Auto-generated catch block
         e1.printStackTrace();
         }


You should run original MTOM example first to be sure you have all
libraries in place.
I am not able to run XFire MTOM under Oracle OC4J 10.1.2 and 10.1.3,
but Weblogic 8.1 SP6 works fine.

Regards,
Zdenek
On 4/23/07, seego <[EMAIL PROTECTED]> wrote:

Hi,

Can someone post an example how to obtain file from serivce?

I mean something like this:

.....
Client client = Client.getInstance(service);
.......
DataHandler dh = service.getFile(file_name_on_server);


For a while I have been trying to solve the problem and had no luck so far.
Funny thing is that I can replicate XFire MTOM examples where client sends
an instance of DataHandler or DataSource to service and receives content as
a String. I assume, if these examples run in my environment than I have
properly configured my service and client. So, why
service.getStringFrom(new DataHandler(new
FileDataSource(file_name_on_clien))) works, and
DataHandler dh = service.getFile(file_name_on_server) doesn't?


You may look at the detailed description of the problem here:
http://www.nabble.com/MTOM.-Can-my-webservice-return-DataHandler--tf3607587.html

Or, may be you can explain the reason for NullPointerException I am getting?

--
View this message in context: 
http://www.nabble.com/How-to-download-large-file-from-service-side-to-client--tf3632140.html#a10141755
Sent from the XFire - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to