Search in sources :

Example 11 with AddressingFeature

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

the class AddressingPolicyMapConfigurator method update.

/**
 * Puts an addressing policy into the PolicyMap if the addressing feature was set.
 */
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);
    Collection<PolicySubject> subjects = new ArrayList<>();
    if (policyMap != null) {
        final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("addressingFeature = " + addressingFeature);
        }
        if ((addressingFeature != null) && addressingFeature.isEnabled()) {
            // add wsam:Addrressing assertion if not exists.
            addWsamAddressing(subjects, policyMap, model, addressingFeature);
        }
    }
    // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
Also used : PolicySubject(com.sun.xml.ws.policy.PolicySubject) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) ArrayList(java.util.ArrayList)

Example 12 with AddressingFeature

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

the class AddressingPolicyMapConfigurator method createWsamAddressingPolicy.

/**
 * Create a policy with an WSAM Addressing assertion.
 */
private Policy createWsamAddressingPolicy(final QName bindingName, AddressingFeature af) {
    final ArrayList<AssertionSet> assertionSets = new ArrayList<>(1);
    final ArrayList<PolicyAssertion> assertions = new ArrayList<>(1);
    final AssertionData addressingData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION);
    if (!af.isRequired()) {
        addressingData.setOptionalAttribute(true);
    }
    try {
        AddressingFeature.Responses responses = af.getResponses();
        if (responses == AddressingFeature.Responses.ANONYMOUS) {
            AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
            PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
            assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
        } else if (responses == AddressingFeature.Responses.NON_ANONYMOUS) {
            final AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
            PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
            assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
        } else {
            assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
        }
    } catch (NoSuchMethodError e) {
        // If JAX-WS 2.2 API is really required, it would been reported in @Addressing or wsam:Addressing processing
        // Don't add any nested assertion to mimic the 2.1 behavior
        assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
    }
    assertionSets.add(AssertionSet.createAssertionSet(assertions));
    return Policy.createPolicy(null, bindingName.getLocalPart() + "_WSAM_Addressing_Policy", assertionSets);
}
Also used : PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) ArrayList(java.util.ArrayList) AssertionSet(com.sun.xml.ws.policy.AssertionSet) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 13 with AddressingFeature

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

the class AddNumbersClient method createDispatchWithoutWSDL.

private Dispatch<SOAPMessage> createDispatchWithoutWSDL() throws Exception {
    Service service = Service.create(SERVICE_QNAME);
    service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
    Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
    return dispatch;
}
Also used : MemberSubmissionAddressingFeature(com.sun.xml.ws.developer.MemberSubmissionAddressingFeature) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) WSService(com.sun.xml.ws.api.WSService) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 14 with AddressingFeature

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

the class AddNumbersClient method createDispatchWithoutWSDL.

private Dispatch<SOAPMessage> createDispatchWithoutWSDL() throws Exception {
    AddNumbersService service = new AddNumbersService();
    Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
    return dispatch;
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 15 with AddressingFeature

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

the class AddNumbersClient method testAddressingWithNoWSDLwithHandler.

public void testAddressingWithNoWSDLwithHandler() throws Exception {
    Service service = Service.create(SERVICE_QNAME);
    service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING, getAddress());
    Dispatch<SOAPMessage> dispatch = service.createDispatch(PORT_QNAME, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature());
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
    dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, ADD_NUMBERS_ACTION);
    String message = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body>" + "<addNumbers xmlns=\"http://example.com/\">" + "<number1>10</number1>" + "<number2>10</number2>" + "</addNumbers>" + "</S:Body></S:Envelope>";
    List<Handler> handlerChain = dispatch.getBinding().getHandlerChain();
    handlerChain.add(new MyHandler());
    dispatch.getBinding().setHandlerChain(handlerChain);
    WsaUtils.invoke(dispatch, message);
}
Also used : AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) Service(jakarta.xml.ws.Service) Handler(jakarta.xml.ws.handler.Handler) SOAPHandler(jakarta.xml.ws.handler.soap.SOAPHandler) SOAPMessage(jakarta.xml.soap.SOAPMessage)

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