Example usage for javax.xml.ws.soap MTOMFeature isEnabled

List of usage examples for javax.xml.ws.soap MTOMFeature isEnabled

Introduction

In this page you can find the example usage for javax.xml.ws.soap MTOMFeature isEnabled.

Prototype

public boolean isEnabled() 

Source Link

Document

Returns true if this feature is enabled.

Usage

From source file:org.apache.axis2.jaxws.client.config.MTOMConfigurator.java

public void configure(MessageContext messageContext, BindingProvider provider) {
    Binding bnd = (Binding) provider.getBinding();
    MTOMFeature mtomFeature = (MTOMFeature) bnd.getFeature(MTOMFeature.ID);
    Message requestMsg = messageContext.getMessage();

    //Disable MTOM.
    requestMsg.setMTOMEnabled(false);/*from   w  w w  . j a va  2 s.c  om*/

    if (mtomFeature == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("mtomFeatureErr"));
    }

    //Enable MTOM if specified.
    if (mtomFeature.isEnabled()) {
        int threshold = mtomFeature.getThreshold();
        List<String> attachmentIDs = requestMsg.getAttachmentIDs();

        // Enable MTOM
        requestMsg.setMTOMEnabled(true);

        if (threshold <= 0) {
            if (log.isDebugEnabled()) {
                log.debug("Enabling MTOM with no threshold.");
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("MTOM Threshold Value =" + threshold);
            }

            //set MTOM threshold value on message context.
            //Once MTOM threshold is set on message context it will be
            //read by SOAPMessageFormatter.writeTo() while writing the attachment
            //SOAPMessageFormatter will further propogate the threshold value to
            //Axiom.OMOutputFormat. JAXBAttachmentUnmarshaller will then make 
            //decision if the attachment should be inlined or optimized.  
            messageContext.setProperty(Constants.Configuration.MTOM_THRESHOLD, new Integer(threshold));
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("The MTOMFeature was found, but not enabled.");
        }
    }
}

From source file:org.seedstack.seed.ws.internal.WSPlugin.java

private boolean checkMtomConflict(MTOMFeature lhs, MTOMFeature rhs) {
    return !(lhs == null || rhs == null) && lhs.isEnabled() ^ rhs.isEnabled();
}