Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Services and the fly likes sending large files through webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "sending large files through webservice" Watch "sending large files through webservice" New topic
Author

sending large files through webservice

Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
what is the best way to send a large files of size around 200 mb from client to a webservice. sending files from client through webservice to server.
i had written a webservice for this but it gives out of memory exception for files of size around 15mb.
is soap attachments a good solution for this?
can anyone please provide some sample code for this implementation
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

Best possible way is to avoid using web service to do this, but in case that you have no other choice you can use SOAP attachment. If you are using GlassFish (METRO stack) or other implementation which support MTOM you may use MTOM optimizations which can be used to transfer big files.

hope it helps.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
Hi Masoud,
i am weblogic as webservice engine. can you please elaborate on MTOM.
if possible can you provide sample code for implementing with SOAP attachment.
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

Which version of Weblogic server you are using?
I think 10+ support JAX-WS and MTOM, so you can use it to optimize your big file transfer. This blog explain MTOM http://blogs.sun.com/milan/entry/using_web_service_to_send
In case that you need to read more about JAX-WS you can take a look at http://metro.dev.java.net this stack used to create weblogic application server web services stack.

You can find many soap attachment sample in bea dev2dev or in google, just try some search patterns and you will find plenty of samples.
pradeep jaladi
Ranch Hand

Joined: Nov 21, 2004
Posts: 65
Hi Satish,

What is your ram size and the JVM s of 2 GB max. Please check the ram sizes. I am able to upload the 1 G.B file using Apache Axis + SOAP Attachment + 3 GB RAM. And possible check the configurations of the web logic attachment size limit.


Pradeep.Jaladi
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
i am using weblogic 8.1 and dont know whether it supports JAX-WS and MTOM.

pradeep,
can you please give sample code or link to upload webservice with soap attachments
pradeep jaladi
Ranch Hand

Joined: Nov 21, 2004
Posts: 65
Hi,

Please find the example in the following Link.

http://www.ibm.com/developerworks/webservices/library/ws-soapatt/


Use DataHandler as a parameter to pass the file.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Satish Kumar:
i am using weblogic 8.1 and dont know whether it supports JAX-WS and MTOM.


Weblogic 8.1 is an implementation of J2EE 1.3.

Web services (JAX-RPC) did not enter the J2EE specification until 1.4.

JAX-WS is part of the Java EE 5 specification.

So neither JAX-WS or MTOM are supported by Weblogic 8.1.

Attachment support is limited to SOAP attachments which aren't universally supported by all SOAP clients (though Java SOAP clients can use SAAJ).

In Weblogic 8.1 SOAP attachments have to be handled through SOAP Message Handlers:

eDocs Home> BEA WebLogic Server 8.1 Documentation> Programming WebLogic Web Services> Creating SOAP Message Handlers to Intercept the SOAP Message> Programming WebLogic Web Services: Creating SOAP Message Handlers to Intercept the SOAP Message

Given the vintage of the implementation I have my doubts that a 200 MB attachment would be handled properly (I'd expect to see a 10 MB limit) - but you would have to test that.

Large file transfers should really be handled by protocols more suited to the task - like FTP. The web service provider would then handle the creation of temporary FTP identities/privileges/credentials and return the necessary information to the web service consumer.

Alternately the files could be managed through a REST-style storage service (Amazon S3, Introduction to Amazon S3 with Java and REST, ParkPlace).
 
Consider Paul's rocket mass heater.
 
subject: sending large files through webservice
 
Similar Threads
Specific Attachment Problem...
what is the maximum size of a data a servlet can send per stream?
Axis2: getInboundFaultFrom MessageContext Error!
Axis2 - Hibernate problem: cannot handle large pojo
.Net Client for Axis Web services