Java 类javax.xml.ws.soap.MTOMFeature 实例源码

项目:OpenJSharp    文件:Packet.java   
private boolean shouldUseMtomOutbound() {
    //Use the getter to make sure all the logic is executed correctly
    MTOMFeature myMtomFeature = getMtomFeature();
    if(myMtomFeature != null && myMtomFeature.isEnabled()) {
        //On client, always use XOP encoding if MTOM is enabled
        //On Server, mtomAcceptable and mtomRequest will be set - use XOP encoding
        //if either request is XOP encoded (mtomRequest) or
        //client accepts XOP encoding (mtomAcceptable)
        if (getMtomAcceptable() == null && getMtomRequest() == null) {
            return true;
        } else {
            if (getMtomAcceptable() != null &&  getMtomAcceptable() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ClientRequest)) {
                return true;
            }
        }
    }
    return false;
}
项目:OpenJSharp    文件:WebServiceFeatureList.java   
/**
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:OpenJSharp    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:OpenJSharp    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:openjdk-jdk10    文件:WebServiceFeatureList.java   
/**
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:openjdk-jdk10    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:openjdk-jdk10    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:openjdk9    文件:WebServiceFeatureList.java   
/**
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:openjdk9    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:openjdk9    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:lookaside_java-1.8.0-openjdk    文件:Packet.java   
private boolean shouldUseMtomOutbound() {
    //Use the getter to make sure all the logic is executed correctly
    MTOMFeature myMtomFeature = getMtomFeature();
    if(myMtomFeature != null && myMtomFeature.isEnabled()) {
        //On client, always use XOP encoding if MTOM is enabled
        //On Server, mtomAcceptable and mtomRequest will be set - use XOP encoding
        //if either request is XOP encoded (mtomRequest) or
        //client accepts XOP encoding (mtomAcceptable)
        if (getMtomAcceptable() == null && getMtomRequest() == null) {
            return true;
        } else {
            if (getMtomAcceptable() != null &&  getMtomAcceptable() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ClientRequest)) {
                return true;
            }
        }
    }
    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:WebServiceFeatureList.java   
/**
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:lookaside_java-1.8.0-openjdk    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:mycarenet    文件:EHealthBoxPublicationClient.java   
/**
 * Main constructor.
 * 
 * @param location
 *            the URL of the eHealth Publication version 3.0 web service.
 */
public EHealthBoxPublicationClient(String location) {
    EhBoxPublicationService publicationService = EhBoxPublicationServiceFactory
            .newInstance();
    /*
     * Nasty way to disable MTOM for Apache CXF.
     */
    this.ehBoxPublicationPort = publicationService
            .getEhBoxPublicationPort(new MTOMFeature(false,
                    1024 * 1024 * 1024));

    QName publicationPortQName = new QName(
            "urn:be:fgov:ehealth:ehbox:publication:protocol:v3",
            "ehBoxPublicationPort");
    this.publicationDispatch = publicationService.createDispatch(
            publicationPortQName, Source.class, Service.Mode.PAYLOAD);

    this.wsSecuritySOAPHandler = new WSSecuritySOAPHandler();
    this.payloadLogicalHandler = new PayloadLogicalHandler();
    configureBindingProvider((BindingProvider) this.ehBoxPublicationPort,
            location);
    configureBindingProvider(this.publicationDispatch, location);
}
项目:infobip-open-jdk-8    文件:Packet.java   
private boolean shouldUseMtomOutbound() {
    //Use the getter to make sure all the logic is executed correctly
    MTOMFeature myMtomFeature = getMtomFeature();
    if(myMtomFeature != null && myMtomFeature.isEnabled()) {
        //On client, always use XOP encoding if MTOM is enabled
        //On Server, mtomAcceptable and mtomRequest will be set - use XOP encoding
        //if either request is XOP encoded (mtomRequest) or
        //client accepts XOP encoding (mtomAcceptable)
        if (getMtomAcceptable() == null && getMtomRequest() == null) {
            return true;
        } else {
            if (getMtomAcceptable() != null &&  getMtomAcceptable() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ClientRequest)) {
                return true;
            }
        }
    }
    return false;
}
项目:infobip-open-jdk-8    文件:WebServiceFeatureList.java   
/**
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:infobip-open-jdk-8    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:infobip-open-jdk-8    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:switchyard    文件:SoapMtomClient.java   
public static Image sendMessage(String wsdl) throws Exception {
    ImageService imageService = new ImageServiceService(new URL(wsdl)).getImageServicePort(new MTOMFeature());

    // Create the Image bytes and send it to the MTOM endpoint...
    URL fileURL = Classes.getResource("switchyard_icon.jpeg");
    File aFile = new File(new URI(fileURL.toString()));
    long fileSize = aFile.length();

    Holder<byte[]> param = new Holder<byte[]>();
    param.value = new byte[(int) fileSize];
    InputStream in = fileURL.openStream();
    int len = in.read(param.value);
    while (len < fileSize) {
        len += in.read(param.value, len, (int) (fileSize - len));
    }
    byte[] response = imageService.resizeImage(param);
    return ImageIO.read(new ByteArrayInputStream(response));
}
项目:opentext    文件:OpentextAdaptor.java   
@Override
public ContentService newContentService(
    DocumentManagement documentManagement) {
  ContentService contentServicePort =
      contentServiceService.getBasicHttpBindingContentService(
          new MTOMFeature());

  setEndpointAddress(
      (BindingProvider) contentServicePort, "ContentService");
  setAuthenticationHandler(
      (BindingProvider) contentServicePort,
      getAuthenticationToken((BindingProvider) documentManagement));
  addSocketTimeoutConfiguration((BindingProvider) contentServicePort);

  return contentServicePort;
}
项目:OLD-OpenJDK8    文件:Packet.java   
private boolean shouldUseMtomOutbound() {
    //Use the getter to make sure all the logic is executed correctly
    MTOMFeature myMtomFeature = getMtomFeature();
    if(myMtomFeature != null && myMtomFeature.isEnabled()) {
        //On client, always use XOP encoding if MTOM is enabled
        //On Server, mtomAcceptable and mtomRequest will be set - use XOP encoding
        //if either request is XOP encoded (mtomRequest) or
        //client accepts XOP encoding (mtomAcceptable)
        if (getMtomAcceptable() == null && getMtomRequest() == null) {
            return true;
        } else {
            if (getMtomAcceptable() != null &&  getMtomAcceptable() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ServerResponse)) {
                return true;
            }
            if (getMtomRequest() != null && getMtomRequest() && getState().equals(State.ClientRequest)) {
                return true;
            }
        }
    }
    return false;
}
项目:OLD-OpenJDK8    文件:WebServiceFeatureList.java   
/**
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:OLD-OpenJDK8    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:OLD-OpenJDK8    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:wso2-axis2    文件:ProxyMTOMFeatureTest.java   
public void testDefaultMTOMFeature() {
    // Use the default feature config
    MTOMFeature feature = new MTOMFeature();

    Service svc = Service.create(new QName("http://test", "ProxyMTOMService"));
    ProxyMTOMService proxy = svc.getPort(ProxyMTOMService.class, feature);
    assertTrue("Proxy instance was null", proxy != null);

    proxy.sendAttachment("12345");

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    assertTrue("Request should not be null.", request != null);
    assertTrue("MTOM should be abled on the Message by default.", request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:ProxyMTOMFeatureTest.java   
public void testDisabledMTOMFeature() {
    // Use the default feature config
    MTOMFeature feature = new MTOMFeature(false);

    Service svc = Service.create(new QName("http://test", "ProxyMTOMService"));
    ProxyMTOMService proxy = svc.getPort(ProxyMTOMService.class, feature);
    assertTrue("Proxy instance was null", proxy != null);

    proxy.sendAttachment("12345");

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    assertTrue("Request should not be null.", request != null);
    assertTrue("MTOM should NOT be abled on the Message by default.", !request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:ProxyMTOMFeatureTest.java   
public void testMTOMFeatureThreshold() {
    // Set a threshold that we will not meet.
    int threshold = 20000;
    MTOMFeature feature = new MTOMFeature(threshold);

    Service svc = Service.create(new QName("http://test", "ProxyMTOMService"));
    ProxyMTOMService proxy = svc.getPort(ProxyMTOMService.class, feature);
    assertTrue("Proxy instance was null", proxy != null);

    proxy.sendAttachment("12345");

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    assertTrue("Request should not be null.", request != null);
    // A Threshold indicates that MTOM should be enabled.
    // The decision about whether the attachment is inlined is made on a per attachment
    // basis in Axiom...and cannot be tested in unit test that does not send the message
    // to the server.
    assertTrue("MTOM should be enabled.", request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:DispatchOperationResolutionTest.java   
/**
 * Validate that doing operation resolution does not impact using a WebServiceFeature such as MTOM on the
 * createDispatch.
 */
public void testOperationResolutionAndMTOMFeature() {
    Service service = Service.create(wsdlDocumentLocation, serviceQName);
    MTOMFeature feature = new MTOMFeature(true);
    Dispatch<String> dispatch = service.createDispatch(portQName, String.class, Service.Mode.MESSAGE, feature);
    assertNotNull(dispatch);

    String result = dispatch.invoke(echoBodyContent_MESSAGE);
    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext requestMC = ic.getRequestMessageContext();

    OperationDescription opDesc = requestMC.getOperationDescription();
    assertNotNull("OpDesc from request MC should not be null", opDesc);
    // Make sure we get the correct Operation Description
    OperationDescription expectedOperationDescription = expectedOperationDescription(requestMC);
    assertSame("Wrong operation description returned", expectedOperationDescription, opDesc);
    assertTrue("MTOM should be enabled via the MTOMFeature.", requestMC.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:DispatchMTOMFeatureTest.java   
public void testDefaultMTOMFeature() {
    // Use the default feature config
    MTOMFeature feature = new MTOMFeature();

    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");
    Dispatch<Source> d = svc.createDispatch(new QName("http://test", "TestPort"), 
        Source.class, Service.Mode.PAYLOAD, feature);

    d.invoke(null);

    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    assertTrue("MTOM should be enabled via the MTOMFeature.", request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:DispatchMTOMFeatureTest.java   
public void testMTOMFeatureThresholdWithNoAttachment() {
    Service svc = Service.create(new QName("http://test", "TestService"));
    svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost");

    // Set the feature to be disabled.
    int threshold = 20000;
    MTOMFeature feature = new MTOMFeature(threshold);

    Dispatch<Source> d = svc.createDispatch(new QName("http://test", "TestPort"), 
        Source.class, Service.Mode.PAYLOAD, feature);

    d.invoke(null);

    TestClientInvocationController testController = getInvocationController();

    InvocationContext ic = testController.getInvocationContext();
    MessageContext request = ic.getRequestMessageContext();

    // A Threshold indicates that MTOM should be enabled.
    // The decision about whether the attachment is inlined is made on a per attachment
    // basis in Axiom...and cannot be tested in unit test that does not send the message
    // to the server.
    assertTrue("MTOM should be enabled.", request.getMessage().isMTOMEnabled());
}
项目:wso2-axis2    文件:EndpointDescriptionImpl.java   
public boolean isMTOMEnabled() {
    if (isMTOMEnabledCache != null) {
        return isMTOMEnabledCache.booleanValue();
    }

    // isMTOMEnabled is a combination of the @BindingType and the @MTOM setting.
    MTOM mtomAnnotation =
            (MTOM) getAnnoFeature(MTOMFeature.ID);

    // If the @MTOM annotation is set, it wins
    if (mtomAnnotation != null) {
        isMTOMEnabledCache = Boolean.valueOf(mtomAnnotation.enabled());
        return isMTOMEnabledCache.booleanValue();
    }

    // Else look at the bindingType
    String bindingType = getBindingType();
    isMTOMEnabledCache = Boolean.valueOf(isMTOMBinding(bindingType));
    return isMTOMEnabledCache.booleanValue();
}
项目:openjdk-icedtea7    文件:WebServiceFeatureList.java   
/**
 * Reads {@link WebServiceFeatureAnnotation feature annotations} on a class
 * and adds them to the list.
 *
 * @param endpointClass web service impl class
 */
public void parseAnnotations(Class<?> endpointClass) {
    for (Annotation a : endpointClass.getAnnotations()) {
        WebServiceFeature ftr = getFeature(a);
        if (ftr != null) {
            if (ftr instanceof MTOMFeature) {
                // check conflict with @BindingType
                BindingID bindingID = BindingID.parse(endpointClass);
                MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
                if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
                    throw new RuntimeModelerException(
                        ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
                }
            }
            add(ftr);
        }
    }
}
项目:openjdk-icedtea7    文件:MtomPolicyMapConfigurator.java   
/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 *
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    } // endif policy map not null

    LOGGER.exiting(subjects);
    return subjects;
}
项目:openjdk-icedtea7    文件:MtomFeatureConfigurator.java   
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                        features.add(new MTOMFeature(true));
                    } // end-if non optional mtom assertion found
                } // next assertion
            } // next alternative
        } // end-if policy contains mtom assertion
    }
    return features;
}
项目:OpenJSharp    文件:MessageContextFactory.java   
private Packet packet(Message m) {
    final Packet p = new Packet();
    //TODO when do we use xmlCodec?
    p.codec = soapCodec;
    if (m != null) p.setMessage(m);
    MTOMFeature mf = features.get(MTOMFeature.class);
    if (mf != null) {
        p.setMtomFeature(mf);
    }
    return p;
}
项目:OpenJSharp    文件:Packet.java   
public MTOMFeature getMtomFeature() {
    //If we have a binding, use that in preference to an explicitly
    //set MTOMFeature
    WSBinding binding = getBinding();
    if (binding != null) {
        return binding.getFeature(MTOMFeature.class);
    }
    return mtomFeature;
}
项目:OpenJSharp    文件:BindingID.java   
@Override
public WebServiceFeatureList createBuiltinFeatureList() {
    WebServiceFeatureList r=super.createBuiltinFeatureList();
    Boolean mtom = isMTOMEnabled();
    if(mtom != null)
        r.add(new MTOMFeature(mtom));
    return r;
}
项目:OpenJSharp    文件:RuntimeModeler.java   
private BindingID getDefaultBindingID() {
BindingType bt = getAnnotation(portClass, BindingType.class);
if (bt != null) return BindingID.parse(bt.value());
SOAPVersion ver = getSoapVersion(features);
boolean mtomEnabled = features.isEnabled(MTOMFeature.class);
if (SOAPVersion.SOAP_12.equals(ver)) {
    return (mtomEnabled) ? BindingID.SOAP12_HTTP_MTOM : BindingID.SOAP12_HTTP;
} else {
    return (mtomEnabled) ? BindingID.SOAP11_HTTP_MTOM : BindingID.SOAP11_HTTP;
}
}
项目:OpenJSharp    文件:MtomCodec.java   
MtomCodec(SOAPVersion version, StreamSOAPCodec codec, WSFeatureList features){
    super(version, features);
    this.codec = codec;
    sf = features.get(SerializationFeature.class);
    MTOMFeature mtom = features.get(MTOMFeature.class);
    if(mtom == null)
        this.mtomFeature = new MTOMFeature();
    else
        this.mtomFeature = mtom;
}