Handle Web Services Large Attachments

Axis2

Upload Files

On the server side, edit axis2\WEB-INF\conf\axis2.xml

<!-- enable one only -->
<parameter name="enableMTOM">false</parameter>
<parameter name="enableSwA">true</parameter>
 
<!--Uncomment if you want to enable file caching for attachments -->
<parameter name="cacheAttachments">true</parameter>
<parameter name="attachmentDIR">c:/temp/axis2</parameter>
<!-- file size LARGER than sizeThreshold value will be CACHED -->
<parameter name="sizeThreshold">4000</parameter>

Download Files

On the client side,

Options options = new Options();
options.setTo(targetEPR);
 
// Do NOT enable both MTOM and SWA if so MTOM takes precedence
//options.setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.ENABLE_SWA,
    Constants.VALUE_TRUE);
 
options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS, Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,"C:\\temp\\axis2");
options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, "4000");
// Increase the time out when sending large attachments
options.setTimeOutInMilliSeconds(1000000);
 
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
This entry was posted in soa. Bookmark the permalink.