Search in sources :

Example 16 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class WebServiceFeatureList method parseAnnotations.

/**
 * @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);
        }
    }
}
Also used : MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) ImpliesWebServiceFeature(com.sun.xml.ws.api.ImpliesWebServiceFeature) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) RuntimeModelerException(com.sun.xml.ws.model.RuntimeModelerException) BindingID(com.sun.xml.ws.api.BindingID) FeatureListValidatorAnnotation(com.sun.xml.ws.api.FeatureListValidatorAnnotation) Annotation(java.lang.annotation.Annotation) WebServiceFeatureAnnotation(jakarta.xml.ws.spi.WebServiceFeatureAnnotation)

Example 17 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class MtomFeatureConfigurator method getFeatures.

/**
 * 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<>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null != policy && policy.contains(EncodingConstants.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 (EncodingConstants.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;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) AssertionSet(com.sun.xml.ws.policy.AssertionSet) LinkedList(java.util.LinkedList)

Example 18 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class MtomPolicyMapConfigurator method update.

/**
 * 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<>();
    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;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySubject(com.sun.xml.ws.policy.PolicySubject) QName(javax.xml.namespace.QName) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) ArrayList(java.util.ArrayList) WsdlBindingSubject(com.sun.xml.ws.policy.subject.WsdlBindingSubject)

Example 19 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class StreamMessageTest method testWriteSwaToStreamClientRequest.

// Bug 17367334
public void testWriteSwaToStreamClientRequest() throws Exception {
    String ctype = "multipart/related; boundary=MIME_Boundary; " + "start=\"<6232425701115978772--54bee05.140acdf4f8a.-7f3f>\"; " + "type=\"text/xml\"; start-info=\"text/xml\"";
    MessageContextFactory mcf = MessageContextFactory.createFactory(new MTOMFeature(true));
    InputStream is = getClass().getClassLoader().getResourceAsStream("etc/bug17367334InputMsg.txt");
    Packet packet = (Packet) mcf.createContext(is, ctype);
    Message message = packet.getInternalMessage();
    assertTrue("StreamMessage not found, got : " + message.getClass(), StreamMessage.class.isAssignableFrom(message.getClass()));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    packet.setState(State.ClientRequest);
    // System.out.println("SWA packet.getContentType(): " + packet.getContentType().getContentType() );
    ContentType contentType = packet.writeTo(baos);
    // System.out.println("etc/bug17367334InputMsg.txt\r\n" + contentType.getContentType() + "\r\n" + new String(baos.toByteArray()));
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    MessageFactory mf = MessageFactory.newInstance();
    MimeHeaders mh = new MimeHeaders();
    mh.addHeader("Content-Type", ctype);
    SOAPMessage sm = mf.createMessage(mh, bais);
    assertEquals("wrong attachment count", 1, sm.countAttachments());
    AttachmentPart ap = (AttachmentPart) sm.getAttachments().next();
    assertEquals("wrong attachemnt Content-Id", "<testAttachmentContentId>", ap.getContentId());
// NodeList nl = sm.getSOAPBody().getElementsByTagNameNS(MtomCodec.XOP_NAMESPACEURI, MtomCodec.XOP_LOCALNAME);
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) SOAPMessage(jakarta.xml.soap.SOAPMessage) ContentType(com.oracle.webservices.api.message.ContentType) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) AttachmentPart(jakarta.xml.soap.AttachmentPart) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SOAPMessage(jakarta.xml.soap.SOAPMessage) MimeHeaders(jakarta.xml.soap.MimeHeaders) MessageContextFactory(com.oracle.webservices.api.message.MessageContextFactory) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 20 with MTOMFeature

use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.

the class MtomAppTest method testUpload.

public void testUpload() throws Exception {
    Hello port = new HelloService().getHelloPort(new MTOMFeature());
    Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
    ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
    Holder<Integer> total = new Holder<Integer>(123456000);
    Holder<String> name = new Holder<String>("huge");
    Holder<DataHandler> dh = new Holder<DataHandler>(getDataHandler(total.value));
    port.upload(total, name, dh);
    if (!"hugehuge".equals(name.value)) {
        fail("FAIL: Expecting: hugehuge Got: " + name.value);
    }
    System.out.println("SUCCESS: Got: " + name.value);
    System.out.println("Going to verify DataHandler. This would take some time");
    validateDataHandler(total.value, dh.value);
    System.out.println("SUCCESS: DataHandler is verified");
}
Also used : MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) Holder(jakarta.xml.ws.Holder) BindingProvider(jakarta.xml.ws.BindingProvider) DataHandler(jakarta.activation.DataHandler) StreamingDataHandler(com.sun.xml.ws.developer.StreamingDataHandler)

Aggregations

MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)22 BindingProvider (jakarta.xml.ws.BindingProvider)7 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)5 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 IOException (java.io.IOException)4 MessageContextFactory (com.oracle.webservices.api.message.MessageContextFactory)3 Message (com.sun.xml.ws.api.message.Message)3 Packet (com.sun.xml.ws.api.message.Packet)3 DataHandler (jakarta.activation.DataHandler)3 AttachmentPart (jakarta.xml.soap.AttachmentPart)3 MessageFactory (jakarta.xml.soap.MessageFactory)3 MimeHeaders (jakarta.xml.soap.MimeHeaders)3 InputStream (java.io.InputStream)3 QName (javax.xml.namespace.QName)3 MessageContext (com.oracle.webservices.api.message.MessageContext)2 BindingID (com.sun.xml.ws.api.BindingID)2 ImpliesWebServiceFeature (com.sun.xml.ws.api.ImpliesWebServiceFeature)2 StreamingDataHandler (com.sun.xml.ws.developer.StreamingDataHandler)2