Search in sources :

Example 6 with AddressingFeature

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

the class WSServiceDelegate method createDispatch.

public <T> Dispatch<T> createDispatch(QName portName, Class<T> aClass, Service.Mode mode, WebServiceFeatureList features) {
    WSEndpointReference wsepr = null;
    boolean isAddressingEnabled = false;
    AddressingFeature af = features.get(AddressingFeature.class);
    if (af == null) {
        af = this.features.get(AddressingFeature.class);
    }
    if (af != null && af.isEnabled())
        isAddressingEnabled = true;
    MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class);
    if (msa == null) {
        msa = this.features.get(MemberSubmissionAddressingFeature.class);
    }
    if (msa != null && msa.isEnabled())
        isAddressingEnabled = true;
    if (isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) {
        wsepr = wsdlService.get(portName).getEPR();
    }
    return createDispatch(portName, wsepr, aClass, mode, features);
}
Also used : MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)

Example 7 with AddressingFeature

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

the class WebServiceFeatureList method getFeature.

/**
 * Returns a corresponding feature for a feature annotation(i.e which has
 * {@link WebServiceFeatureAnnotation} meta annotation)
 *
 * @return corresponding feature for the annotation
 *         null, if the annotation is nota feature annotation
 */
public static WebServiceFeature getFeature(Annotation a) {
    WebServiceFeature ftr = null;
    if (!(a.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class))) {
        ftr = null;
    } else if (a instanceof Addressing) {
        Addressing addAnn = (Addressing) a;
        try {
            ftr = new AddressingFeature(addAnn.enabled(), addAnn.required(), addAnn.responses());
        } catch (NoSuchMethodError e) {
            // throw error. We can't default to Responses.ALL as we dont know if the user has not used 2.2 annotation with responses.
            throw new RuntimeModelerException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(Addressing.class))));
        }
    } else if (a instanceof MTOM) {
        MTOM mtomAnn = (MTOM) a;
        ftr = new MTOMFeature(mtomAnn.enabled(), mtomAnn.threshold());
    } else if (a instanceof RespectBinding) {
        RespectBinding rbAnn = (RespectBinding) a;
        ftr = new RespectBindingFeature(rbAnn.enabled());
    } else {
        ftr = getWebServiceFeatureBean(a);
    }
    return ftr;
}
Also used : MTOM(jakarta.xml.ws.soap.MTOM) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) RespectBindingFeature(jakarta.xml.ws.RespectBindingFeature) ImpliesWebServiceFeature(com.sun.xml.ws.api.ImpliesWebServiceFeature) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) RespectBinding(jakarta.xml.ws.RespectBinding) RuntimeModelerException(com.sun.xml.ws.model.RuntimeModelerException) Addressing(jakarta.xml.ws.soap.Addressing)

Example 8 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortVIIII.

public void testEPRGetPortVIIII() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    // EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    RespectBindingFeature feature = new RespectBindingFeature(true);
    AddressingFeature addr = new AddressingFeature(true, false);
    WebServiceFeature[] features = new WebServiceFeature[] { feature, addr };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    // expectation is that port is not configured for addressing and the invocation will fail
    try {
        System.out.println("Adding numbers 2 and 4");
        int result = port.addNumbers(2, 4);
    } catch (Exception ex) {
        assertTrue(ex instanceof SOAPFaultException);
        System.out.println(((SOAPFaultException) ex).getFault().getFaultString());
    }
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 9 with AddressingFeature

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

the class AddNumbersClient method testEPRGetPortV.

public void testEPRGetPortV() throws Exception {
    if (ClientServerTestUtil.useLocal()) {
        System.out.println("HTTP Transport Only Exiting");
        return;
    }
    AddNumbersPortType proxy = createStub();
    // EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(W3CEndpointReference.class);
    EndpointReference epr = ((BindingProvider) proxy).getEndpointReference(MemberSubmissionEndpointReference.class);
    // force addressing off
    AddressingFeature feature = new AddressingFeature(false, false);
    WebServiceFeature[] features = new WebServiceFeature[] { feature };
    AddNumbersPortType port = epr.getPort(AddNumbersPortType.class, features);
    assertTrue(port != null);
    System.out.println("Adding numbers 2 and 4");
    int result = port.addNumbers(2, 4);
    assert (result == 6);
    System.out.println("Addinion of 2 and 4 successful");
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) MemberSubmissionEndpointReference(com.sun.xml.ws.developer.MemberSubmissionEndpointReference)

Example 10 with AddressingFeature

use of jakarta.xml.ws.soap.AddressingFeature 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)

Aggregations

AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)41 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)21 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)17 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)16 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)11 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)10 QName (javax.xml.namespace.QName)7 JAXBElement (jakarta.xml.bind.JAXBElement)5 Service (jakarta.xml.ws.Service)5 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 IOException (java.io.IOException)4 BindingImpl (com.sun.xml.ws.binding.BindingImpl)3 JAXBContext (jakarta.xml.bind.JAXBContext)3 BindingProvider (jakarta.xml.ws.BindingProvider)3 Endpoint (jakarta.xml.ws.Endpoint)3 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 WSBinding (com.sun.xml.ws.api.WSBinding)2 AssertionSet (com.sun.xml.ws.policy.AssertionSet)2