0

Working on a JAX-WS web-service on WAS 8.0 to upload/download large files >100MB. With file streaming as an option for such large files, I've come across the StreamingDataHandler and StreamingAttachmentFeature both of which are features only available via the Metro GlassFish implementation of JAX-WS or WebLogic implementation.

Working with WAS 8.0 I have ruled them out as options and have implemented a web service with just DataHandler and MTOM annotation to upload and download files. On the client side I've enabled MTOMFeature and set the value for JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE ("com.sun.xml.ws.transport.http.client.streaming.chunk.size").

My question is two pronged: 1. Is it possible to actually implement file streaming transfer with just the above classes/annotations? 2. If yes, how do i confirm with a 100% certainty that the files are indeed being streamed?

1 Answers1

1

I had the same requirements i.e., handling large files coming in payload without bloating the memory. I had to bump up JVM heap size to 2G to get non-streaming based solution handle concurrent file uploads. Until implemented streaming based solution, I was using Weblogic 10.3.5, which has built-in JAX-WS RI 2.1.5.

  1. MTOM annotations optimize the transmission over the wire, i.e., sending/receiving binary data (as HTTP multi-part message binary attachment) instead of base64 encoded string. In order to enable streaming based payload handling within your webservice you need to use below annotation, in addition to @MTOM

    @StreamingAttachment(parseEagerly = true, memoryThreshold = 40000L)

This annotation comes from SUN JAX-WS RI package : import com.sun.xml.ws.developer.StreamingAttachment;

Plus, use DataHandler typed JAXB data field along with below annotation :

@XmlMimeType("application/octet-stream")

protected DataHandler data;

  1. Yes, you can tell if streaming is working by either monitoring JVM heap size (I noticed it jumps up to 700MB used heap memory for 100MB attachment due to string based handling of payload i.e., in non-streaming mode). Or you can log the class name of your data field, it would be something like "StreamingDataHandler" (which extends from DataHandler). If you use Eclipse or similar debugger and put a break-point there (inside you endpoint class) and look in to received payload, you shall notice that "data" is referring to Streaming handler concrete class.

    log.debug("Data handler class : " + stream.getClass().getName());
    
Rajesh
  • 1,600
  • 5
  • 33
  • 59
Irfan
  • 31
  • 4