Example usage for javax.xml.namespace QName toString

List of usage examples for javax.xml.namespace QName toString

Introduction

In this page you can find the example usage for javax.xml.namespace QName toString.

Prototype

public String toString() 

Source Link

Document

<p><code>String</code> representation of this <code>QName</code>.</p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.apache.axis2.context.MessageContext.java

/**
 * This method checks to see if additional work needs to be
 * done in order to complete the object reconstitution.
 * Some parts of the object restored from the readExternal()
 * cannot be completed until we have an object that gives us
 * a view of the active object graph from the active engine.
 * <p/>/*from   www .j  av a2  s .co m*/
 * NOTE: when activating an object, you only need to call
 * one of the activate methods (activate() or activateWithOperationContext())
 * but not both.
 *
 * @param operationCtx The operation context object that is a member of the active object graph
 */
public void activateWithOperationContext(OperationContext operationCtx) {
    // see if there's any work to do
    if (!(needsToBeReconciled)) {
        // return quick
        return;
    }

    String logCorrelationIDString = getLogIDString();
    // trace point
    if (DEBUG_ENABLED && log.isTraceEnabled()) {
        log.trace(logCorrelationIDString + ":activateWithOperationContext():  BEGIN");
    }

    if (operationCtx == null) {
        // won't be able to finish
        if (DEBUG_ENABLED && log.isTraceEnabled()) {
            log.trace(logCorrelationIDString
                    + ":activateWithOperationContext():  *** WARNING ***  No active OperationContext object is available.");
        }
        return;
    }

    //---------------------------------------------------------------------
    // locate the objects in the object graph
    //---------------------------------------------------------------------
    ConfigurationContext configCtx = operationCtx.getConfigurationContext();

    if (configCtx == null) {
        // won't be able to finish
        if (DEBUG_ENABLED && log.isTraceEnabled()) {
            log.trace(logCorrelationIDString
                    + ":activateWithOperationContext():  *** WARNING ***  No active ConfigurationContext object is available.");
        }
        return;
    }

    AxisConfiguration axisCfg = configCtx.getAxisConfiguration();

    AxisOperation axisOp = operationCtx.getAxisOperation();
    ServiceContext serviceCtx = operationCtx.getServiceContext();

    ServiceGroupContext serviceGroupCtx = null;
    AxisService axisSrv = null;
    AxisServiceGroup axisSG = null;

    if (serviceCtx != null) {
        serviceGroupCtx = serviceCtx.getServiceGroupContext();
        axisSrv = serviceCtx.getAxisService();
    }

    if (serviceGroupCtx != null) {
        axisSG = serviceGroupCtx.getDescription();
    }

    //---------------------------------------------------------------------
    // link to the objects in the object graph
    //---------------------------------------------------------------------

    setConfigurationContext(configCtx);

    setAxisOperation(axisOp);
    setAxisService(axisSrv);
    setAxisServiceGroup(axisSG);

    setServiceGroupContext(serviceGroupCtx);
    setServiceContext(serviceCtx);
    setOperationContext(operationCtx);

    //---------------------------------------------------------------------
    // reconcile the remaining objects
    //---------------------------------------------------------------------

    // We previously saved metaAxisMessage; restore it
    if (metaAxisMessage != null) {
        if (axisOp != null) {
            // TODO: check for the empty name
            this.setAxisMessage(ActivateUtils.findMessage(axisOp, metaAxisMessage.getQNameAsString(),
                    metaAxisMessage.getExtraName()));
        }
    }

    //---------------------------------------------------------------------
    // options
    //---------------------------------------------------------------------
    if (options != null) {
        options.activate(configCtx);
    }

    String tmpID = getMessageID();

    if (DEBUG_ENABLED && log.isTraceEnabled()) {
        log.trace(logCorrelationIDString + ":activateWithOperationContext():   message ID [" + tmpID + "]");
    }

    //---------------------------------------------------------------------
    // transports
    //---------------------------------------------------------------------

    // We previously saved metaTransportIn; restore it
    if (metaTransportIn != null) {
        QName qin = metaTransportIn.getQName();
        TransportInDescription tmpIn = null;
        try {
            tmpIn = axisCfg.getTransportIn(qin.getLocalPart());
        } catch (Exception exin) {
            // if a fault is thrown, log it and continue
            if (DEBUG_ENABLED && log.isTraceEnabled()) {
                log.trace(logCorrelationIDString
                        + "activateWithOperationContext():  exception caught when getting the TransportInDescription ["
                        + qin.toString() + "]  from the AxisConfiguration [" + exin.getClass().getName() + " : "
                        + exin.getMessage() + "]");
            }

        }

        if (tmpIn != null) {
            transportIn = tmpIn;
        } else {
            transportIn = null;
        }
    } else {
        transportIn = null;
    }

    // We previously saved metaTransportOut; restore it
    if (metaTransportOut != null) {
        QName qout = metaTransportOut.getQName();
        TransportOutDescription tmpOut = null;
        try {
            tmpOut = axisCfg.getTransportOut(qout.getLocalPart());
        } catch (Exception exout) {
            // if a fault is thrown, log it and continue
            if (DEBUG_ENABLED && log.isTraceEnabled()) {
                log.trace(logCorrelationIDString
                        + "activateWithOperationContext():  exception caught when getting the TransportOutDescription ["
                        + qout.toString() + "]  from the AxisConfiguration [" + exout.getClass().getName()
                        + " : " + exout.getMessage() + "]");
            }
        }

        if (tmpOut != null) {
            transportOut = tmpOut;
        } else {
            transportOut = null;
        }
    } else {
        transportOut = null;
    }

    //-------------------------------------------------------
    // reconcile the execution chain
    //-------------------------------------------------------
    if (metaExecutionChain != null) {
        if (DEBUG_ENABLED && log.isTraceEnabled()) {
            log.trace(logCorrelationIDString
                    + ":activateWithOperationContext(): reconciling the execution chain...");
        }

        currentHandlerIndex = metaHandlerIndex;
        currentPhaseIndex = metaPhaseIndex;

        executionChain = restoreHandlerList(metaExecutionChain);

        try {
            deserializeSelfManagedData();
        } catch (Exception ex) {
            // log the exception
            if (DEBUG_ENABLED && log.isTraceEnabled()) {
                log.trace(logCorrelationIDString
                        + ":activateWithOperationContext(): *** WARNING *** deserializing the self managed data encountered Exception ["
                        + ex.getClass().getName() + " : " + ex.getMessage() + "]", ex);
            }
        }
    }

    //-------------------------------------------------------
    // reconcile the lists for the executed phases
    //-------------------------------------------------------
    if (metaExecuted != null) {
        if (DEBUG_ENABLED && log.isTraceEnabled()) {
            log.trace(logCorrelationIDString
                    + ":activateWithOperationContext(): reconciling the executed chain...");
        }

        if (!(executedPhasesReset)) {
            executedPhases = restoreExecutedList(executedPhases, metaExecuted);
        }
    }

    if (executedPhases == null) {
        executedPhases = new LinkedList<Handler>();
    }

    //-------------------------------------------------------
    // done, reset the flag
    //-------------------------------------------------------
    needsToBeReconciled = false;

    if (DEBUG_ENABLED && log.isTraceEnabled()) {
        log.trace(logCorrelationIDString + ":activateWithOperationContext():  END");
    }
}

From source file:org.apache.axis2.description.WSDL20ToAxisServiceBuilder.java

private void createAxisMessage(AxisOperation axisOperation, InterfaceMessageReference messageReference,
        String messageLabel) throws AxisFault {
    AxisMessage message = axisOperation.getMessage(messageLabel);

    String messageContentModelName = messageReference.getMessageContentModel();
    QName elementQName = null;/* w  w w .  j  a  va 2s.  c o m*/

    if (WSDL2Constants.NMTOKEN_ELEMENT.equals(messageContentModelName)) {
        ElementDeclaration elementDeclaration = messageReference.getElementDeclaration();
        if (elementDeclaration == null) {
            InterfaceMessageReferenceElement messageReferenceElement = messageReference.toElement();
            QName qName = messageReferenceElement.getElement().getQName();
            throw new AxisFault("Unable to find element " + qName.toString() + " reffered to by operation "
                    + axisOperation.getName().getLocalPart());
        }
        elementQName = elementDeclaration.getName();
    } else if (WSDL2Constants.NMTOKEN_ANY.equals(messageContentModelName)) {
        elementQName = Constants.XSD_ANY;
    } else if (WSDL2Constants.NMTOKEN_NONE.equals(messageContentModelName)) {
        // nothing to do here keep the message element as null
    } else {
        throw new AxisFault("Sorry we do not support " + messageContentModelName
                + ". We do only support #any, #none and #element as message content models.");
    }

    message.setElementQName(elementQName);
    message.setName(
            elementQName != null ? elementQName.getLocalPart() : axisOperation.getName().getLocalPart());
    axisOperation.addMessage(message, messageLabel);

    if (WSDLConstants.MESSAGE_LABEL_IN_VALUE.equals(messageLabel)) {
        XMLAttr xa = messageReference.toElement()
                .getExtensionAttribute(new QName("http://www.w3.org/2006/05/addressing/wsdl", "Action"));
        if (xa != null) {
            String value = (String) xa.getContent();
            if (value != null) {
                ArrayList al = axisOperation.getWSAMappingList();
                if (al == null) {
                    al = new ArrayList();
                    axisOperation.setWsamappingList(al);
                }
                al.add(value);
            }
        }
    } else {
        XMLAttr xa = messageReference.toElement()
                .getExtensionAttribute(new QName("http://www.w3.org/2006/05/addressing/wsdl", "Action"));
        if (xa != null) {
            String value = (String) xa.getContent();
            if (value != null) {
                axisOperation.setOutputAction(value);
            }
        }
    }

    // populate this map so that this can be used in SOAPBody based dispatching
    if (elementQName != null) {
        axisService.addMessageElementQNameToOperationMapping(elementQName, axisOperation);
    }
}

From source file:org.apache.axis2.jaxws.addressing.factory.impl.Axis2EndpointReferenceFactoryImpl.java

public EndpointReference createEndpointReference(String address, QName serviceName, QName portName,
        String wsdlDocumentLocation, String addressingNamespace) {
    EndpointReference axis2EPR = null;

    if (address != null) {
        if (serviceName == null && portName != null) {
            throw new IllegalStateException(
                    Messages.getMessage("axisEndpointReferenceFactoryErr", portName.toString()));
        }/*w  w w . j  av a2  s .  c  o m*/
        axis2EPR = createEndpointReference(address);
    } else if (serviceName != null && portName != null) {
        axis2EPR = createEndpointReference(serviceName, portName);
    } else {
        throw new IllegalStateException(Messages.getMessage("axisEndpointReferenceFactoryErr2"));
    }

    //TODO If no service name and port name are specified, but the wsdl location is
    //specified, and the WSDL only contains one service and one port then maybe we
    //should simply use those.        
    try {
        //This code is locate here instead of in the createEndpointReference(QName, QName)
        //method so that if the address is also specified the EPR metadata will still be
        //filled in correctly.
        EndpointReferenceUtils.addService(axis2EPR, serviceName, portName, addressingNamespace);

        if (wsdlDocumentLocation != null) {

            URL wsdlURL;
            try {
                wsdlURL = new URL(wsdlDocumentLocation);
            } catch (MalformedURLException e) {
                // just to keep it clean:
                if (axis2EPR.getAddress().endsWith("/") && wsdlDocumentLocation.startsWith("/")) {
                    wsdlDocumentLocation = axis2EPR.getAddress() + wsdlDocumentLocation.substring(1);

                } else if (axis2EPR.getAddress().endsWith("/")) {
                    String eprAddress = axis2EPR.getAddress();
                    wsdlDocumentLocation = eprAddress.substring(0, eprAddress.length() - 1)
                            + wsdlDocumentLocation;

                } else {
                    wsdlDocumentLocation = axis2EPR.getAddress() + wsdlDocumentLocation;
                }
            }

            wsdlURL = new URL(wsdlDocumentLocation);
            // This is a temporary usage, so use a memory sensitive wrapper
            WSDLWrapper wrapper = new WSDL4JWrapper(wsdlURL, true, 2);

            if (serviceName != null) {

                QName serviceNameNoTrailingSlash = new QName("");
                // TODO: why in the world would we have to do this?
                if (serviceName.getNamespaceURI().endsWith("/")) {
                    String ns = serviceName.getNamespaceURI();
                    serviceNameNoTrailingSlash = new QName(ns.substring(0, ns.length() - 1),
                            serviceName.getLocalPart());
                }

                if ((wrapper.getService(serviceName) == null)
                        && (wrapper.getService(serviceNameNoTrailingSlash) == null)) {
                    throw new IllegalStateException(Messages.getMessage("MissingServiceName",
                            serviceName.toString(), wsdlDocumentLocation));
                }
                if (portName != null) {
                    String[] ports = wrapper.getPorts(serviceName);
                    // search the other name.  TODO: again, why do we have to do this?
                    if (ports == null) {
                        ports = wrapper.getPorts(serviceNameNoTrailingSlash);
                    }
                    String portLocalName = portName.getLocalPart();
                    boolean found = false;

                    if (ports != null) {
                        for (String port : ports) {
                            // TODO: axis2 perhaps is deploying with "TypeImplPort" appended, but not reading/honoring the WSDL?
                            if (port.equals(portLocalName) || (port + "TypeImplPort").equals(portLocalName)) {
                                log.debug("found port: " + port);
                                found = true;
                                break;
                            }
                        }
                    }

                    if (!found) {
                        throw new IllegalStateException(Messages.getMessage("MissingPortName",
                                portName.toString(), wsdlDocumentLocation));
                    }
                    log.debug("Setting wsdlDocumentLocation to " + wsdlDocumentLocation
                            + " for EndpointReference at port " + portName);
                    EndpointReferenceUtils.addLocation(axis2EPR, portName.getNamespaceURI(),
                            wsdlDocumentLocation, addressingNamespace);
                }
            }
        }
    } catch (IllegalStateException ise) {
        throw ise;
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointRefCreationError"), e);
    }
    return axis2EPR;
}

From source file:org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.java

/**
 * @see org.apache.axis2.jaxws.description.DescriptionFactory#updateEndpoint(ServiceDescription,
 * Class, EndpointReference, String, DescriptionFactory.UpdateType, DescriptionBuilderComposite, Object)
 *//*from  w ww  . j  av a 2s .co m*/
public static EndpointDescription updateEndpoint(ServiceDescription serviceDescription, Class sei,
        EndpointReference epr, String addressingNamespace, DescriptionFactory.UpdateType updateType,
        DescriptionBuilderComposite composite, Object sparseCompositeKey, String bindingId,
        String endpointAddress) {
    QName portQName = null;

    try {
        ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(epr, addressingNamespace);
        QName serviceQName = serviceDescription.getServiceQName();

        //We need to throw an exception if the service name in the EPR metadata does not
        //match the service name associated with the JAX-WS service instance.
        if (serviceName.getName() != null && !serviceQName.equals(serviceName.getName())) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceNameMismatch",
                    serviceName.getName().toString(), serviceQName.toString()));
        }
        //If a port name is available from the EPR metadata then use that, otherwise
        //leave it to the runtime to find a suitable port, based on WSDL/annotations.
        if (serviceName.getEndpointName() != null) {
            portQName = new QName(serviceQName.getNamespaceURI(), serviceName.getEndpointName());
        }
    } catch (Exception e) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("updateEndpointError", e.getMessage()));
    }

    return updateEndpoint(serviceDescription, sei, portQName, updateType, composite, sparseCompositeKey,
            bindingId, endpointAddress);
}

From source file:org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.java

/**
 * Update or create an EndpointDescription. Updates to existing EndpointDescriptons will be
 * based on the SEI class and its annotations.  Both declared ports and dynamic ports can be
 * updated.  A declared port is one that is defined (e.g. in WSDL or via annotations); a dyamic
 * port is one that is not defined (e.g. not via WSDL or annotations) and has been added via
 * Serivce.addPort.//from   ww  w .  j av  a2 s. c o  m
 * <p/>
 * For predefined ports, a composite of sparse metadata, such as from a deployment descriptor
 * may be supplied.  This can be used to modify the endpoint interfaceannotations such as
 * adding a handler chain.  The sparse composite is NOT supported for dynamic (i.e. ADD_PORT)
 * or dispatch clients. 
 * <p/>
 * Notes on how an EndpointDescription can be updated or created: 1) Service.createDispatch can
 * create a Dispatch client for either a declared or dynamic port 2) Note that creating a
 * Dispatch does not associate an SEI with an endpoint 3) Service.getPort will associate an SEI
 * with a port 4) A getPort on an endpoint which was originally created for a Distpatch will
 * update that EndpointDescription with the SEI provided on the getPort 5) Service.getPort can
 * not be called on a dynamic port (per the JAX-WS spec) 6) Service.addPort can not be called
 * for a declared port
 *
 * @param sei        This will be non-null if the update is of type GET_PORT; it will be null if
 *                   the update is ADD_PORT or CREATE_DISPATCH
 * @param portQName
 * @param updateType Indicates what is causing the update GET_PORT is an attempt to get a
 *                   declared SEI-based port ADD_PORT is an attempt to add a previously
 *                   non-existent dynamic port CREATE_DISPATCH is an attempt to create a
 *                   Dispatch-based client to either a declared port or a pre-existing dynamic
 *                   port.
 * @param composite  May contain sparse metadata, for example from a deployment descriptor, that
 *                   should be used in conjunction with the class annotations to update the
 *                   description hierarchy.  For example, it may contain a HandlerChain annotation
 *                   based on information in a JSR-109 deployment descriptor.                    
 */

EndpointDescription updateEndpointDescription(Class sei, QName portQName,
        DescriptionFactory.UpdateType updateType, DescriptionBuilderComposite composite,
        Object serviceDelegateKey, String bindingId, String endpointAddress) {

    EndpointDescriptionImpl endpointDescription = getEndpointDescriptionImpl(portQName);
    boolean isPortDeclared = isPortDeclared(portQName);

    // If a defined endpointDescription is not available, try and locate a dynamic endpoint.
    // Note that a dynamic port will only be found for the client that created it, per the
    // serviceDelegateKey

    if (endpointDescription == null && serviceDelegateKey != null) {
        endpointDescription = getDynamicEndpointDescriptionImpl(portQName, serviceDelegateKey);
    }

    // If no QName was specified in the arguments, one may have been specified in the sparse
    // composite metadata when the service was created.
    if (DescriptionUtils.isEmpty(portQName)) {
        QName preferredPortQN = getPreferredPort(serviceDelegateKey);
        if (!DescriptionUtils.isEmpty(preferredPortQN)) {
            portQName = preferredPortQN;
        }
    }

    switch (updateType) {

    case ADD_PORT:
        if (composite != null) {
            throw ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("serviceDescErr5", portQName.toString()));
        }
        // Port must NOT be declared (e.g. can not already exist in WSDL)
        // If an EndpointDesc doesn't exist; create it as long as it doesn't exist in the WSDL
        if (DescriptionUtils.isEmpty(portQName)) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("addPortErr2"));
        }
        if (getWSDLWrapper() != null && isPortDeclared) {
            throw ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("addPortDup", portQName.toString()));
        } else if (endpointDescription == null) {
            // Use the SEI Class and its annotations to finish creating the Description hierarchy.  Note that EndpointInterface, Operations, Parameters, etc.
            // are not created for dynamic ports.  It would be an error to later do a getPort against a dynamic port (per the JAX-WS spec)
            // If we can't add the dynamic port under a specific service delegate, that is an error

            if (serviceDelegateKey == null) {
                throw ExceptionFactory
                        .makeWebServiceException(Messages.getMessage("serviceDescriptionImplAddPortErr"));
            }

            endpointDescription = createEndpointDescriptionImpl(sei, portQName, bindingId, endpointAddress);
            addDynamicEndpointDescriptionImpl(endpointDescription, serviceDelegateKey);

        } else {
            // All error chJeck above passed, the EndpointDescription already exists and needs no updating
        }
        break;

    case GET_PORT:

        // try to find existing endpointDesc by SEI class if portQName was not specified 
        if (endpointDescription == null && portQName == null && sei != null) {
            endpointDescription = getEndpointDescriptionImpl(sei);
        }

        // If an endpointDesc doesn't exist, and the port exists in the WSDL, create it
        // If an endpointDesc already exists and has an associated SEI already, make sure they match
        // If an endpointDesc already exists and was created for Dispatch (no SEI), update that with the SEI provided on the getPort

        // Port must be declared (e.g. in WSDL or via annotations)
        // TODO: Once isPortDeclared understands annotations and not just WSDL, the 2nd part of this check can possibly be removed.
        //       Although consider the check below that updates an existing EndpointDescritpion with an SEI.
        if (!isPortDeclared || (endpointDescription != null && endpointDescription.isDynamicPort())) {
            // This guards against the case where an addPort was done previously and now a getPort is done on it.
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("updateEPDescrErr1",
                    (portQName != null ? portQName.toString() : "not specified")));
        } else if (sei == null) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("updateEPDescrErr2",
                    (portQName != null ? portQName.toString() : "not specified")));
        } else if (endpointDescription == null) {
            // Use the SEI Class and its annotations to finish creating the Description hierachy: Endpoint, EndpointInterface, Operations, Parameters, etc.
            endpointDescription = new EndpointDescriptionImpl(sei, portQName, this, composite,
                    serviceDelegateKey);
            addEndpointDescription(endpointDescription);
            /*
             * We must reset the service runtime description after adding a new endpoint
             * since the runtime description information could have references to old
             * information. See MarshalServiceRuntimeDescriptionFactory and 
             * MarshalServiceRuntimeDescription.
             */
            resetServiceRuntimeDescription();
        } else if (getEndpointSEI(portQName) == null && !endpointDescription.isDynamicPort()) {
            // Existing endpointDesc from a declared port needs to be updated with an SEI.
            // This could happen if the client first did a CREATE_DISPATCH on a declared
            // port, which would cause it to be created, and then did a GET_PORT on the 
            // same port later, providing an SEI.
            // Notes 
            // 1) An EndpointDescritption created from an addPort (i.e. a dynamic port) can 
            //    not do this.
            // 2) A sparse composite may be specified.  We don't allow mixing JAX-WS unmanaged
            //    apis (CREATE_DISPATCH) with JSR-109 managed apis (GET_PORT with sparse
            //    composite metadata from a DD).  Since the sparse composite is stored by
            //    a key AND CREATE_DISPATCH and ADD_PORT will thrown an exception of a composite
            //    is specified, having a composite and key on the GET_PORTs shouldn't be
            //    a problem.
            endpointDescription.updateWithSEI(sei, composite, serviceDelegateKey);
        } else if (getEndpointSEI(portQName) != sei) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("updateEPDescrErr3",
                    portQName.toString(), sei.getName(), getEndpointSEI(portQName).getName()));
        } else {
            // All error check above passed, the EndpointDescription already exists and needs no updating
            // Just add the sparse composite if one was specified.
            endpointDescription.getDescriptionBuilderComposite().setSparseComposite(serviceDelegateKey,
                    composite);
        }
        break;

    case CREATE_DISPATCH:
        if (composite != null) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceDescErr6"));
        }

        // Port may or may not exist in WSDL.
        // If an endpointDesc doesn't exist and it is in the WSDL, it can be created
        // Otherwise, it is an error.
        if (DescriptionUtils.isEmpty(portQName)) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("createDispatchFail0"));
        } else if (endpointDescription != null) {
            // The EndpointDescription already exists; nothing needs to be done
        } else if (sei != null) {
            // The Dispatch should not have an SEI associated with it on the update call.
            throw ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("createDispatchFail3", portQName.toString()));
        } else if (getWSDLWrapper() != null && isPortDeclared) {
            // EndpointDescription doesn't exist and this is a declared Port, so create one
            // Use the SEI Class and its annotations to finish creating the Description hierarchy.  
            // Note that EndpointInterface, Operations, Parameters, etc. are not created for 
            // Dispatch-based ports, but might be updated later if a getPort is done against 
            // the same declared port.
            endpointDescription = new EndpointDescriptionImpl(sei, portQName, this);
            addEndpointDescription(endpointDescription);
        } else {
            // The port is not a declared port and it does not have an EndpointDescription, 
            // meaning an addPort has not been done for it
            // This is an error.
            throw ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("createDispatchFail1", portQName.toString()));
        }
        break;
    }
    return endpointDescription;
}

From source file:org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.java

private EndpointDescriptionImpl createEndpointDescriptionImpl(Class sei, QName portQName, String bindingId,
        String endpointAddress) {
    if (log.isDebugEnabled()) {
        log.debug("Calling createEndpointDescriptionImpl : (" + portQName + "," + bindingId + ","
                + endpointAddress + ")");
    }// www .  ja  v a2s. c om
    EndpointDescriptionImpl endpointDescription = null;
    AxisConfiguration configuration = configContext.getAxisConfiguration();
    if (log.isDebugEnabled()) {
        log.debug("looking for " + JAXWS_DYNAMIC_ENDPOINTS + " in AxisConfiguration : " + configuration);
    }
    Parameter parameter = configuration.getParameter(JAXWS_DYNAMIC_ENDPOINTS);
    HashMap cachedDescriptions = (HashMap) ((parameter == null) ? null : parameter.getValue());
    if (cachedDescriptions == null) {
        cachedDescriptions = new HashMap();
        try {
            configuration.addParameter(JAXWS_DYNAMIC_ENDPOINTS, cachedDescriptions);
        } catch (AxisFault axisFault) {
            throw new RuntimeException(axisFault);
        }
        if (log.isDebugEnabled()) {
            log.debug("Added new instance of cachedDescriptions : " + cachedDescriptions);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("found old jaxws.dynamic.endpoints cache in AxisConfiguration (" + cachedDescriptions
                    + ") with size : (" + cachedDescriptions.size() + ")");
        }
    }

    StringBuffer key = new StringBuffer();
    key.append(portQName == null ? "NULL" : portQName.toString());
    key.append(':');
    key.append(bindingId == null ? "NULL" : bindingId);
    key.append(':');
    key.append(endpointAddress == null ? "NULL" : endpointAddress);
    synchronized (cachedDescriptions) {
        WeakReference ref = (WeakReference) cachedDescriptions.get(key.toString());
        if (ref != null) {
            endpointDescription = (EndpointDescriptionImpl) ref.get();
        }
    }
    if (endpointDescription == null) {
        endpointDescription = new EndpointDescriptionImpl(sei, portQName, true, this);
        synchronized (cachedDescriptions) {
            if (log.isDebugEnabled()) {
                log.debug("Calling cachedDescriptions.put : (" + key.toString() + ") : size - "
                        + cachedDescriptions.size());
            }
            cachedDescriptions.put(key.toString(), new WeakReference(endpointDescription));
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("found old entry for endpointDescription in jaxws.dynamic.endpoints cache : ("
                    + cachedDescriptions.size() + ")");
        }
    }
    return endpointDescription;
}

From source file:org.apache.axis2.jaxws.handler.HandlerUtils.java

private static void checkUnprocessed(SOAPEnvelope envelope, List<QName> unprocessed, List<QName> understood,
        MessageContext msgContext) throws AxisFault {
    for (QName headerQName : unprocessed) {
        if (understood != null && !understood.isEmpty()) {
            if (understood.contains(headerQName)) {
                if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
                    log.debug(/*from  w w w  . j  a  v  a 2 s  .c  om*/
                            "MustUnderstand header registered as understood on AxisOperation: " + headerQName);
                }
                continue;
            }
        }
        if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
            log.debug("MustUnderstand header not processed or registered as understood " + headerQName);
        }
        // Throw a MustUnderstand fault for the current SOAP version
        String prefix = envelope.getNamespace().getPrefix();
        if (!msgContext.isSOAP11()) {
            if (prefix == null || "".equals(prefix)) {
                prefix = SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX;
            }
            // TODO: should we be using a prefix on the faultcode?  What about
            // the QName object Constants.FAULT_SOAP12_MUSTUNDERSTAND?
            throw new AxisFault(Messages.getMessage("mustunderstandfailed", prefix, headerQName.toString()),
                    SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND);
        } else {
            // TODO: should we be using a prefix on the faultcode?  What about
            // the QName object Constants.FAULT_MUSTUNDERSTAND?
            throw new AxisFault(Messages.getMessage("mustunderstandfailed", prefix, headerQName.toString()),
                    SOAP11Constants.FAULT_CODE_MUST_UNDERSTAND);
        }
    }
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

@Override
public <T> Dispatch<T> createDispatch(QName portName, Class<T> type, Mode mode, WebServiceFeature... features) {

    if (log.isDebugEnabled()) {
        log.debug("Create Dispatch with portName: " + portName);
    }//from  www . j av a2 s . c o  m
    verifyServiceDescriptionActive();
    if (portName == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("createDispatchFail0"));
    }

    if (!isValidDispatchType(type)) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidType"));
    }

    if (!isValidDispatchTypeWithMode(type, mode)) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidTypeWithMode"));
    }

    EndpointDescription endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, null, portName,
            DescriptionFactory.UpdateType.CREATE_DISPATCH, this);

    if (endpointDesc == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("createDispatchFail2", portName.toString()));
    }

    XMLDispatch<T> dispatch = new XMLDispatch<T>(this, endpointDesc, features);

    if (mode != null) {
        dispatch.setMode(mode);
    } else {
        dispatch.setMode(Service.Mode.PAYLOAD);
    }

    if (serviceClient == null)
        serviceClient = getServiceClient(portName);

    if (type == OMElement.class) {
        if (log.isDebugEnabled()) {
            log.debug("This a Dispatch<OMElement>. The custom builder is installed.");
        }
        ProviderOMContextListener.create(serviceClient.getServiceContext());
    }
    dispatch.setServiceClient(serviceClient);
    dispatch.setType(type);
    return dispatch;
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

@Override
public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Mode mode,
        WebServiceFeature... features) {
    if (log.isDebugEnabled()) {
        log.debug("Create Dispatch with jaxbcontext and portName: " + portName);
    }/*from  ww w  . j  a v  a2 s  .  com*/

    verifyServiceDescriptionActive();
    if (portName == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("createDispatchFail0"));
    }

    EndpointDescription endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, null, portName,
            DescriptionFactory.UpdateType.CREATE_DISPATCH, this);

    if (endpointDesc == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("createDispatchFail2", portName.toString()));
    }

    JAXBDispatch<Object> dispatch = new JAXBDispatch(this, endpointDesc, features);

    if (mode != null) {
        dispatch.setMode(mode);
    } else {
        dispatch.setMode(Service.Mode.PAYLOAD);
    }

    if (serviceClient == null)
        serviceClient = getServiceClient(portName);

    dispatch.setJAXBContext(context);
    dispatch.setServiceClient(serviceClient);

    return dispatch;
}

From source file:org.apache.axis2.jaxws.spi.ServiceDelegate.java

@Override
public <T> T getPort(QName portName, Class<T> sei, WebServiceFeature... features) {
    verifyServiceDescriptionActive();//from w  ww. j a v a 2  s.co  m
    /* TODO Check to see if WSDL Location is provided.
     * if not check WebService annotation's WSDLLocation
     * if both are not provided then throw exception.
     * (JLB): I'm not sure lack of WSDL should cause an exception
     */

    if (!isValidWSDLLocation()) {
        //TODO: Should I throw Exception if no WSDL
        //throw ExceptionFactory.makeWebServiceException("WSLD Not found");
    }
    if (sei == null) {
        throw ExceptionFactory
                .makeWebServiceException(Messages.getMessage("getPortInvalidSEI", portName.toString(), "null"));
    }

    DescriptionBuilderComposite sparseComposite = getPortMetadata();
    resetPortMetadata();
    EndpointDescription endpointDesc = null;
    if (sparseComposite != null) {
        endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, sei, portName,
                DescriptionFactory.UpdateType.GET_PORT, sparseComposite, this);
    } else {
        endpointDesc = DescriptionFactory.updateEndpoint(serviceDescription, sei, portName,
                DescriptionFactory.UpdateType.GET_PORT, null, this);

    }
    if (endpointDesc == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("portErr", portName.toString()));
    }

    String[] interfacesNames = new String[] { sei.getName(),
            org.apache.axis2.jaxws.spi.BindingProvider.class.getName() };

    // As required by java.lang.reflect.Proxy, ensure that the interfaces
    // for the proxy are loadable by the same class loader. 
    Class[] interfaces = null;
    // First, let's try loading the interfaces with the SEI classLoader
    ClassLoader classLoader = getClassLoader(sei);
    try {
        interfaces = loadClasses(classLoader, interfacesNames);
    } catch (ClassNotFoundException e1) {
        // Let's try with context classLoader now
        classLoader = getContextClassLoader();
        try {
            interfaces = loadClasses(classLoader, interfacesNames);
        } catch (ClassNotFoundException e2) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("portErr1"), e2);
        }
    }

    JAXWSProxyHandler proxyHandler = new JAXWSProxyHandler(this, interfaces[0], endpointDesc, features);
    Object proxyClass = Proxy.newProxyInstance(classLoader, interfaces, proxyHandler);
    return sei.cast(proxyClass);
}