Search in sources :

Example 26 with WebServiceFeature

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

the class EclipselinkJAXBBasicTest method testCollectionMap.

public void testCollectionMap() throws Exception {
    Class<?> endpointClass = CollectionMapImpl.class;
    Class<?> proxySEIClass = CollectionMap.class;
    DatabindingConfig srvConfig = new DatabindingConfig();
    srvConfig.setEndpointClass(endpointClass);
    DatabindingModeFeature dbm = databindingMode();
    WebServiceFeature[] f = { dbm };
    srvConfig.setFeatures(f);
    DatabindingConfig cliConfig = new DatabindingConfig();
    cliConfig.setContractClass(proxySEIClass);
    cliConfig.setFeatures(f);
    CollectionMap p = createProxy(CollectionMap.class, srvConfig, cliConfig, false);
    {
        List<String> req = Arrays.asList("x", "Eclipselink", "parameterized", "List");
        List<String> res = p.echoListOfString(req);
        assertEqualList(req, res);
    }
    {
        Integer[] num = { 123, -456, 789, 0 };
        Map<String, Integer> req = new HashMap<String, Integer>();
        for (Integer i : num) req.put(i.toString(), i);
        Map<Integer, String> res = p.echoMapOfString(req);
        Map<Integer, String> ans = new HashMap<Integer, String>();
        for (Integer i : num) ans.put(i, i.toString());
        assertTrue(equalsMap(ans, res));
    }
}
Also used : CollectionMapImpl(com.sun.xml.ws.test.CollectionMapImpl) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) CollectionMap(com.sun.xml.ws.test.CollectionMap) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap) CollectionMap(com.sun.xml.ws.test.CollectionMap)

Example 27 with WebServiceFeature

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

the class FastInfosetFeatureConfigurator method getFeatures.

/**
 * Process FastInfoset policy assertions.
 *
 * @param key Key to identify the endpoint scope.
 * @param policyMap the policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final 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_FI_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_FI_SERIALIZATION_ASSERTION.equals(assertion.getName())) {
                        String value = assertion.getAttributeValue(enabled);
                        boolean isFastInfosetEnabled = Boolean.valueOf(value.trim());
                        features.add(new FastInfosetFeature(isFastInfosetEnabled));
                    }
                // end-if non optional fast infoset assertion found
                }
            // next assertion
            }
        // next alternative
        }
    // end-if policy contains fast infoset assertion
    }
    return features;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) AssertionSet(com.sun.xml.ws.policy.AssertionSet) LinkedList(java.util.LinkedList) FastInfosetFeature(com.sun.xml.ws.api.fastinfoset.FastInfosetFeature)

Example 28 with WebServiceFeature

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

the class DeploymentDescriptorParser method parseAdapters.

private List<A> parseAdapters(XMLStreamReader reader) throws IOException, XMLStreamException {
    if (!reader.getName().equals(QNAME_ENDPOINTS)) {
        failWithFullName("runtime.parser.invalidElement", reader);
    }
    List<A> adapters = new ArrayList<>();
    String version = getMandatoryNonEmptyAttribute(reader, ATTR_VERSION);
    if (!version.equals(ATTRVALUE_VERSION_1_0)) {
        failWithLocalName("sun-jaxws.xml's version attribut runtime.parser.invalidVersionNumber", reader, version);
    }
    while (nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        if (reader.getName().equals(QNAME_ENDPOINT)) {
            String name = getMandatoryNonEmptyAttribute(reader, ATTR_NAME);
            if (!names.add(name)) {
                logger.log(Level.WARNING, "sun-jaxws.xml contains duplicate endpoint names. " + "The first duplicate name is = {0}", name);
            }
            String implementationName = getMandatoryNonEmptyAttribute(reader, ATTR_IMPLEMENTATION);
            Class<?> implementorClass = getImplementorClass(implementationName, reader);
            QName serviceName = getQNameAttribute(reader, ATTR_SERVICE);
            QName portName = getQNameAttribute(reader, ATTR_PORT);
            ArrayList<WebServiceFeature> features = new ArrayList<>();
            // get enable-mtom attribute value
            String enable_mtom = getAttribute(reader, ATTR_ENABLE_MTOM);
            String mtomThreshold = getAttribute(reader, ATTR_MTOM_THRESHOLD_VALUE);
            if (Boolean.valueOf(enable_mtom)) {
                if (mtomThreshold != null) {
                    features.add(new MTOMFeature(true, Integer.parseInt(mtomThreshold)));
                } else {
                    features.add(new MTOMFeature(true));
                }
            }
            String bindingId = getAttribute(reader, ATTR_BINDING);
            if (bindingId != null) {
                // Convert short-form tokens to API's binding ids
                bindingId = getBindingIdForToken(bindingId);
            }
            String urlPattern = getMandatoryNonEmptyAttribute(reader, ATTR_URL_PATTERN);
            // boolean handlersSetInDD = setHandlersAndRoles(binding, reader, serviceName, portName);
            nextElementContent(reader);
            ensureNoContent(reader);
            List<Source> metadata = new ArrayList<>();
            for (URL url : docs) {
                Source source = new StreamSource(url.openStream(), url.toExternalForm());
                metadata.add(source);
            }
            adapters.add(adapterFactory.createAdapter(name, urlPattern, implementorClass, serviceName, portName, bindingId, metadata, features.toArray(new WebServiceFeature[0])));
        } else {
            failWithLocalName("runtime.parser.invalidElement", reader);
        }
    }
    return adapters;
}
Also used : QName(javax.xml.namespace.QName) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) URL(java.net.URL) WebServiceFeature(jakarta.xml.ws.WebServiceFeature)

Example 29 with WebServiceFeature

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

the class AddressingFeatureConfigurator method getFeatures.

public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(key, policyMap);
    final Collection<WebServiceFeature> features = new LinkedList<>();
    if ((key != null) && (policyMap != null)) {
        final Policy policy = policyMap.getEndpointEffectivePolicy(key);
        for (QName addressingAssertionQName : ADDRESSING_ASSERTIONS) {
            if ((policy != null) && policy.contains(addressingAssertionQName)) {
                final Iterator<AssertionSet> assertions = policy.iterator();
                while (assertions.hasNext()) {
                    final AssertionSet assertionSet = assertions.next();
                    final Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                    while (policyAssertion.hasNext()) {
                        final PolicyAssertion assertion = policyAssertion.next();
                        if (assertion.getName().equals(addressingAssertionQName)) {
                            final WebServiceFeature feature = AddressingVersion.getFeature(addressingAssertionQName.getNamespaceURI(), true, !assertion.isOptional());
                            if (LOGGER.isLoggable(Level.FINE)) {
                                LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
                            }
                            features.add(feature);
                        }
                    // end-if non optional wsa assertion found
                    }
                // next assertion
                }
            // next alternative
            }
        // end-if policy contains wsa assertion
        }
        // Deal with WS-Addressing 1.0 Metadata assertions
        if (policy != null && policy.contains(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
            for (AssertionSet assertions : policy) {
                for (PolicyAssertion assertion : assertions) {
                    if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
                        NestedPolicy nestedPolicy = assertion.getNestedPolicy();
                        boolean requiresAnonymousResponses = false;
                        boolean requiresNonAnonymousResponses = false;
                        if (nestedPolicy != null) {
                            requiresAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
                            requiresNonAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
                        }
                        if (requiresAnonymousResponses && requiresNonAnonymousResponses) {
                            throw new WebServiceException("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion");
                        }
                        final WebServiceFeature feature;
                        try {
                            if (requiresAnonymousResponses) {
                                feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.ANONYMOUS);
                            } else if (requiresNonAnonymousResponses) {
                                feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.NON_ANONYMOUS);
                            } else {
                                feature = new AddressingFeature(true, !assertion.isOptional());
                            }
                        } catch (NoSuchMethodError e) {
                            throw LOGGER.logSevereException(new PolicyException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(AddressingFeature.class))), e));
                        }
                        if (LOGGER.isLoggable(Level.FINE)) {
                            LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
                        }
                        features.add(feature);
                    }
                }
            }
        }
    }
    LOGGER.exiting(features);
    return features;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) NestedPolicy(com.sun.xml.ws.policy.NestedPolicy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) AssertionSet(com.sun.xml.ws.policy.AssertionSet) LinkedList(java.util.LinkedList) PolicyException(com.sun.xml.ws.policy.PolicyException) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) NestedPolicy(com.sun.xml.ws.policy.NestedPolicy)

Example 30 with WebServiceFeature

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

the class ClientTest method test.

public void test() throws SOAPException, IOException {
    // -- TEST different SOAPACTION properties in RequestContext
    File file = new File("testcases/externalmetadata/fromjava/client/external-wsdl-customization-client.xml");
    WebServiceFeature feature = ExternalMetadataFeature.builder().addFiles(file).build();
    FAKENAME port = new EchoImplService().getFAKENAMEPort(feature);
    Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
    // THIS next line is causing the SOAPACTION http header to go blank, if fix JAX_WS-1049 not applied ...
    requestContext.keySet();
    port.doSomething();
    // -- TEST dispatch: http://java.net/jira/browse/JAX_WS-1014 : Bug <12883765>
    String jaxwsMsg = "<?xml version='1.0' encoding='UTF-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body><doSomething xmlns=\"overriden-target-namespace\"/></S:Body></S:Envelope>";
    EchoImplService service = new EchoImplService();
    Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName("overriden-target-namespace", "FAKE-NAMEPort"), SOAPMessage.class, Service.Mode.MESSAGE);
    Map<String, List> headersMap = new HashMap<String, List>();
    headersMap.put("X-ExampleHeader2", Collections.singletonList("Value"));
    Map<String, Object> context = dispatch.getRequestContext();
    context.put(MessageContext.HTTP_REQUEST_HEADERS, headersMap);
    context.put(SOAPACTION_USE_PROPERTY, Boolean.TRUE);
    MimeHeaders mhs = new MimeHeaders();
    mhs.addHeader("My-Content-Type", "text/xml");
    mhs.addHeader("SOAPAction", "overridenInputAction");
    SOAPMessage msg = MessageFactory.newInstance().createMessage(mhs, new ByteArrayInputStream(jaxwsMsg.getBytes()));
    dispatch.invoke(msg);
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) BindingProvider(jakarta.xml.ws.BindingProvider) SOAPMessage(jakarta.xml.soap.SOAPMessage) MimeHeaders(jakarta.xml.soap.MimeHeaders) ByteArrayInputStream(java.io.ByteArrayInputStream) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) List(java.util.List) File(java.io.File)

Aggregations

WebServiceFeature (jakarta.xml.ws.WebServiceFeature)52 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)19 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)19 QName (javax.xml.namespace.QName)13 BindingImpl (com.sun.xml.ws.binding.BindingImpl)6 SchemaInfo (com.sun.xml.ws.db.sdo.SchemaInfo)6 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 File (java.io.File)6 Method (java.lang.reflect.Method)6 Map (java.util.Map)6 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)5 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)5 HashMap (java.util.HashMap)5 Databinding (com.oracle.webservices.api.databinding.Databinding)4 DatabindingFactory (com.oracle.webservices.api.databinding.DatabindingFactory)4 JavaCallInfo (com.oracle.webservices.api.databinding.JavaCallInfo)4 ImpliesWebServiceFeature (com.sun.xml.ws.api.ImpliesWebServiceFeature)4 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)4 BindingContext (com.sun.xml.ws.spi.db.BindingContext)4 HelperContext (commonj.sdo.helper.HelperContext)4