Example usage for javax.xml.namespace QName getLocalPart

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

Introduction

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

Prototype

public String getLocalPart() 

Source Link

Document

Get the local part of this QName.

Usage

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;

    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());
        }//  www . ja v  a  2s .  co m
        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.engine.AxisConfiguration.java

/**
 * Engages the default module version corresponding to the given module name,
 * or if the module name contains version number in it then it will engage
 * the correct module. Both the below cases are valid : -
 * 1. engageModule("addressing"); 2. engageModule("addressing-1.23");
 *
 * @param moduleref QName of module to engage
 * @throws AxisFault//w w w.j a v  a2  s .  c  om
 * @deprecated Please use the String version instead
 */
public void engageModule(QName moduleref) throws AxisFault {
    engageModule(moduleref.getLocalPart());
}

From source file:org.apache.axis2.engine.AxisConfiguration.java

/**
 * Find out whether a given module is engaged.
 *
 * This method needs to remain for a few Axis2 releases to support
 * legacy apps still using it.  It will be disappearing in 1.6.
 *
 * @param qname QName of the module//from  ww w .  j a  va  2  s  .c  o m
 * @deprecated Use {@link #isEngaged(String)}
 * @return true if a module matching the passed QName is engaged globally
 */
public boolean isEngaged(QName qname) {
    return isEngaged(qname.getLocalPart());
}

From source file:org.apache.axis2.engine.SpeakingHandler1.java

public SpeakingHandler1(String message, QName name) {
    this.message = message;
    HandlerDescription handlerDesc = new HandlerDescription();
    handlerDesc.setName("SpeakingHandler1");
    PhaseRule rule = new PhaseRule();
    rule.setPhaseName(PhaseMetadata.PHASE_DISPATCH);
    handlerDesc.setRules(rule);/*from w ww  .ja va  2s .  com*/
    handlerDesc.setHandler(this);
    handlerDesc.setName(name.getLocalPart());
    init(handlerDesc);
}

From source file:org.apache.axis2.integration.UtilsTCPServer.java

public static synchronized void unDeployService(QName service) throws AxisFault {
    receiver.getConfigurationContext().getAxisConfiguration().removeService(service.getLocalPart());
}

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()));
        }/* www  .j av  a 2 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.client.dispatch.BaseDispatch.java

/**
 * Returns the OperationDescription corresponding to the bodyElementQName passed in.  What that body element corresponds to
 * depends on the type of the message://w w  w  .j a va2  s .  c  om
 * - For Doc/Lit/Wrapped, the body element is the operation name
 * - For Doc/Lit/Bare, the body element is the element name contained in the wsdl:message wsdl:part
 * - For RPC, the body element is effectively the operation name.
 * 
 * @param endpointInterfaceDesc The interface (i.e. SEI) on which to search for the operation
 * @param bodyElementQName the QName of the first body element for which to find the operation
 * 
 * @return The OperationDescription corresponding to the body element QName or null if one can not be found.
 */
private OperationDescription determineOperationDescFromBodyElementQName(
        EndpointInterfaceDescription endpointInterfaceDesc, QName bodyElementQName) {
    OperationDescription operationDesc = null;

    // If there's no bodyElementQName for us to work with, there's nothing more we can do.
    if (bodyElementQName != null) {
        // This logic mimics the code in SOAPMessageBodyBasedOperationDispatcher.findOperation.  We will look for
        // the AxisOperation corresponding to the body element name.  Note that we are searching for the AxisOperation instead
        // of searching through the OperationDescriptions so that we can use the getOperationByMessageElementQName
        // for the Doc/Lit/Bare case.  Once we have the AxisOperation, we'll use that to find the Operation Description.
        AxisService axisService = endpointInterfaceDesc.getEndpointDescription().getAxisService();
        AxisOperation axisOperation = null;

        // Doc/Lit/Wrapped and RPC, the operation name is the first body element qname
        axisOperation = axisService.getOperation(new QName(bodyElementQName.getLocalPart()));

        if (axisOperation == null) {
            // Doc/Lit/Bare, the first body element qname is the element name contained in the wsdl:message part
            axisOperation = axisService.getOperationByMessageElementQName(bodyElementQName);
        }

        if (axisOperation == null) {
            // Not sure why we wouldn't have found the operation above using just the localPart rather than the full QName used here,
            // but this is what SOAPMessageBodyBasedOperationDispatcher.findOperation does.
            axisOperation = axisService.getOperation(bodyElementQName);
        }

        // If we found an axis operation, then find the operation description that corresponds to it
        if (axisOperation != null) {
            OperationDescription allOpDescs[] = endpointInterfaceDesc.getDispatchableOperations();
            for (OperationDescription checkOpDesc : allOpDescs) {
                AxisOperation checkAxisOperation = checkOpDesc.getAxisOperation();
                if (checkAxisOperation == axisOperation) {
                    operationDesc = checkOpDesc;
                    break;
                }
            }
        }
    }
    return operationDesc;
}

From source file:org.apache.axis2.jaxws.context.utils.ContextUtils.java

public static void addWSDLProperties(MessageContext jaxwsMessageContext,
        SOAPMessageContext soapMessageContext) {
    OperationDescription op = jaxwsMessageContext.getOperationDescription();

    if (op != null && soapMessageContext != null) {
        setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.WSDL_OPERATION, op.getName(), true);

        EndpointInterfaceDescription eid = op.getEndpointInterfaceDescription();
        if (eid != null) {
            EndpointDescription ed = eid.getEndpointDescription();
            QName portType = eid.getPortType();
            if (portType == null || portType.getLocalPart().length() == 0) {
                if (log.isDebugEnabled()) {
                    log.debug(//from  w w  w  . j a v a 2 s  .c  o  m
                            "Did not get port type from EndpointInterfaceDescription, attempting to get PortType from EndpointDescription");
                }
            }
            if (ed != null) {
                setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.WSDL_PORT,
                        ed.getPortQName(), true);
            }
            setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.WSDL_INTERFACE, portType, true);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Unable to read WSDL operation, port and interface properties");
        }
    }
}

From source file:org.apache.axis2.jaxws.description.builder.DescriptionBuilderUtils.java

static boolean isEmpty(QName qname) {
    return qname == null || isEmpty(qname.getLocalPart());
}

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

/**
 * Return an array of Operations given an operation QName.  Note that an array is returned since
 * a WSDL operation may be overloaded per JAX-WS.
 *
 * @param operationQName/*from   w w  w. ja v  a 2 s . co  m*/
 * @return
 */
public OperationDescription[] getOperation(QName operationQName) {
    OperationDescription[] returnOperations = null;
    if (!DescriptionUtils.isEmpty(operationQName)) {
        ArrayList<OperationDescription> matchingOperations = new ArrayList<OperationDescription>();
        OperationDescription[] allOperations = getOperations();
        for (OperationDescription operation : allOperations) {
            if (operation.getName().getLocalPart().equals(operationQName.getLocalPart())) {
                matchingOperations.add(operation);
            }
        }
        // Only return an array if there's anything in it
        if (matchingOperations.size() > 0) {
            returnOperations = matchingOperations.toArray(new OperationDescription[0]);
        }
    }
    return returnOperations;
}