Example usage for javax.xml.ws.soap AddressingFeature ID

List of usage examples for javax.xml.ws.soap AddressingFeature ID

Introduction

In this page you can find the example usage for javax.xml.ws.soap AddressingFeature ID.

Prototype

String ID

To view the source code for javax.xml.ws.soap AddressingFeature ID.

Click Source Link

Document

Constant value identifying the AddressingFeature

Usage

From source file:org.apache.axis2.jaxws.common.config.AddressingWSDLExtensionValidator.java

/**
 * Performs validation of input extensionSets from RespectBindingConfigurator.
 * @param extensionSet - Set of found required=true extensions from WSDL, read WSDLValidatorElement object definition.
 * @param wsdlDefinition - a WSDL definition instance.
 * @param endpointDesc - EndpointDescription that describes JAX-WS Endpoint definition.
 *//*w  w  w  .j a  va 2 s  .  c o m*/
public void validate(Set<WSDLValidatorElement> extensionSet, Definition wsdlDefinition,
        EndpointDescription endpointDesc) {
    if (debug) {
        log.debug("Looking for WSDL extension elements to validate");
    }

    if (extensionSet.isEmpty()) {
        if (debug) {
            log.debug("No WSDL extension elements found to validate");
        }
        return;
    }

    if (debug) {
        log.debug("Processing WSDL extension elements");
    }

    Iterator<WSDLValidatorElement> extensionIterator = extensionSet.iterator();

    WSDLValidatorElement elementToValidate;
    while (extensionIterator.hasNext()) {
        elementToValidate = extensionIterator.next();

        if (elementToValidate.getState() == WSDLValidatorElement.State.NOT_RECOGNIZED) {
            ExtensibilityElement ee = elementToValidate.getExtensionElement();
            QName name = (ee != null) ? ee.getElementType() : null;
            if ((name != null) && (name
                    .equals(new QName("http://www.w3.org/2006/05/addressing/wsdl", "UsingAddressing")))) {

                if (debug) {
                    log.debug(
                            "Found WSDL extension element {http://www.w3.org/2006/05/addressing/wsdl,UsingAddressing} -- validating");
                }

                EndpointDescriptionJava edj = (EndpointDescriptionJava) endpointDesc;
                Annotation anno = edj.getAnnoFeature(AddressingFeature.ID);
                if (getFeatureFromAnnotation(anno) == null) {
                    if (debug) {
                        log.debug(
                                "Enabling addressing annotation was not found, so this extension element is not supported");
                    }
                    elementToValidate.setState(WSDLValidatorElement.State.NOT_SUPPORTED);
                } else {
                    if (debug) {
                        log.debug(
                                "The matching addressing annotation was found, so this extension element is supported");
                    }
                    elementToValidate.setState(WSDLValidatorElement.State.SUPPORTED);
                }
            }
        }
    }
}

From source file:org.apache.axis2.jaxws.server.config.AddressingConfigurator.java

public void configure(EndpointDescription endpointDescription) {
    if (log.isDebugEnabled()) {
        log.debug("Start configure");
    }//from ww w  . j a v a  2 s.c o  m
    Addressing addressing = (Addressing) ((EndpointDescriptionJava) endpointDescription)
            .getAnnoFeature(AddressingFeature.ID);
    SubmissionAddressing submissionAddressing = (SubmissionAddressing) ((EndpointDescriptionJava) endpointDescription)
            .getAnnoFeature(SubmissionAddressingFeature.ID);
    Parameter namespace = new Parameter(AddressingConstants.WS_ADDRESSING_VERSION, null);
    Parameter disabled = new Parameter(AddressingConstants.DISABLE_ADDRESSING_FOR_IN_MESSAGES, "false");
    Parameter required = new Parameter(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER,
            AddressingConstants.ADDRESSING_UNSPECIFIED);
    Parameter responses = null;

    if (addressing != null && submissionAddressing != null) {
        if (log.isDebugEnabled()) {
            log.debug("Both Addressing and SubmissionAddressing are specified");
        }
        //Both annotations must have been specified.
        boolean w3cAddressingEnabled = addressing.enabled();
        boolean submissionAddressingEnabled = submissionAddressing.enabled();

        if (w3cAddressingEnabled && submissionAddressingEnabled) {
            namespace.setValue(null);

            boolean w3cAddressingRequired = addressing.required();
            boolean submissionAddressingRequired = submissionAddressing.required();

            if (w3cAddressingRequired || submissionAddressingRequired)
                required.setValue(AddressingConstants.ADDRESSING_REQUIRED);
        } else if (w3cAddressingEnabled) {
            namespace.setValue(AddressingConstants.Final.WSA_NAMESPACE);

            if (addressing.required())
                required.setValue(AddressingConstants.ADDRESSING_REQUIRED);
        } else if (submissionAddressingEnabled) {
            namespace.setValue(AddressingConstants.Submission.WSA_NAMESPACE);

            if (submissionAddressing.required())
                required.setValue(AddressingConstants.ADDRESSING_REQUIRED);
        } else {
            disabled.setValue("true");
        }
    } else if (addressing != null) {
        if (log.isDebugEnabled()) {
            log.debug("Only Addressing is specified.  SubmissionAddressing is not specified");
        }
        //The Addressing annotation must have been specified.
        boolean w3cAddressingEnabled = addressing.enabled();

        if (w3cAddressingEnabled) {
            namespace.setValue(AddressingConstants.Final.WSA_NAMESPACE);

            if (addressing.required())
                required.setValue(AddressingConstants.ADDRESSING_REQUIRED);
        } else {
            namespace.setValue(AddressingConstants.Submission.WSA_NAMESPACE);
        }
    } else if (submissionAddressing != null) {
        if (log.isDebugEnabled()) {
            log.debug("Only SubmssionAddressing is specified.  Addressing is not specified");
        }
        //The SubmissionAddressing annotation must have been specified.
        boolean submissionAddressingEnabled = submissionAddressing.enabled();

        if (submissionAddressingEnabled) {
            namespace.setValue(AddressingConstants.Submission.WSA_NAMESPACE);

            if (submissionAddressing.required())
                required.setValue(AddressingConstants.ADDRESSING_REQUIRED);
        } else {
            namespace.setValue(AddressingConstants.Final.WSA_NAMESPACE);
        }
    } else {
        //If neither were specified then this configurator should never run.
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("NoWSAddressingFeatures"));
    }

    // If the Addressing annotation was used, then get the responses value from it and map it to the 
    // value the addressing handler expects
    if (addressing != null) {
        responses = new Parameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME,
                mapResponseAttributeToAddressing(addressing.responses()));
    }

    try {
        AxisService service = endpointDescription.getAxisService();
        service.addParameter(namespace);
        service.addParameter(disabled);
        service.addParameter(required);
        if (responses != null) {
            service.addParameter(responses);
        }

        String value = Utils.getParameterValue(disabled);
        if (JavaUtils.isFalseExplicitly(value)) {
            ServiceDescription sd = endpointDescription.getServiceDescription();
            AxisConfiguration axisConfig = sd.getAxisConfigContext().getAxisConfiguration();
            if (!axisConfig.isEngaged(Constants.MODULE_ADDRESSING))
                axisConfig.engageModule(Constants.MODULE_ADDRESSING);
        }
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug("Unexpected Exception occurred:", e);
        }
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("AddressingEngagementError", e.toString()));
    }
    if (log.isDebugEnabled()) {
        log.debug("End configure");
    }
}