Example usage for javax.xml.namespace QName QName

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

Introduction

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

Prototype

public QName(final String namespaceURI, final String localPart) 

Source Link

Document

QName constructor specifying the Namespace URI and local part.

If the Namespace URI is null, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .

Usage

From source file:org.apache.servicemix.audit.async.TestSupport.java

protected ActivationSpec createActivationSpec(String name, Object component) {
    ActivationSpec spec = new ActivationSpec(component);
    spec.setComponentName(name);/*  ww w .j a  va  2 s.com*/
    spec.setService(new QName("urn:test", name));
    spec.setEndpoint(name);
    return spec;
}

From source file:org.maodian.flyingcat.xmpp.extensions.xep0077.RegistrationCodec.java

@Override
public Object decode(XMLStreamReader xmlsr) {
    try {/*from w  w  w. j av a  2  s.  c om*/
        xmlsr.require(XMLStreamConstants.START_ELEMENT, InBandRegistration.REGISTER, "query");
        String username = null;
        String password = null;

        while (xmlsr.nextTag() == XMLStreamConstants.START_ELEMENT) {
            if (xmlsr.getName().equals(new QName(InBandRegistration.REGISTER, "username"))) {
                username = xmlsr.getElementText();
            } else if (xmlsr.getName().equals(new QName(InBandRegistration.REGISTER, "password"))) {
                password = xmlsr.getElementText();
            }
        }
        return new Registration(username, password);
    } catch (XMLStreamException e) {
        throw new XmppException(e, StreamError.INVALID_XML);
    }
}

From source file:edu.internet2.middleware.shibboleth.common.config.relyingparty.RelyingPartyGroupBeanDefinitionParser.java

/** {@inheritDoc} */
protected void doParse(Element config, ParserContext parserContext, BeanDefinitionBuilder builder) {
    Map<QName, List<Element>> configChildren = XMLHelper.getChildElements(config);

    List<Element> mds = configChildren.get(new QName(MetadataNamespaceHandler.NAMESPACE, "MetadataProvider"));
    if (mds != null && mds.size() > 0) {
        Element mdConfigElem = mds.get(0);
        SpringConfigurationUtils.parseCustomElement(mdConfigElem, parserContext);
        builder.addPropertyValue("metadataProvider",
                new RuntimeBeanReference(mdConfigElem.getAttributeNS(null, "id")));
    }/*w  ww  .j av a2s.  c o  m*/

    parseRelyingPartyConfiguration(configChildren, builder, parserContext);

    parseSecurityConfiguration(configChildren, builder, parserContext);
}

From source file:eu.esdihumboldt.hale.io.xslt.XslTransformationUtil.java

/**
 * Create a XPath statement to select instances specified by the given type
 * entity definition./*from w w w . jav  a 2s  .c o  m*/
 * 
 * @param ted the type entity definition
 * @param context the context for the XPath expression, e.g. the empty
 *            string for the document root or <code>/</code> for anywhere in
 *            the document
 * @param namespaces the namespace context
 * @return the XPath expression or <code>null</code> if there are no
 *         elements that match the type
 */
public static String selectInstances(TypeEntityDefinition ted, String context, NamespaceContext namespaces) {
    TypeDefinition type = ted.getDefinition();

    // get the XML elements associated to the type
    XmlElements elements = type.getConstraint(XmlElements.class);

    if (elements.getElements().isEmpty()) {
        /*
         * XXX dirty hack
         * 
         * In CityGML 1.0 no element for AppearanceType is defined, only a
         * property that is not detected in this way. The source route
         * element is not known here, so we also cannot do a search based on
         * the type. Thus for now we handle it as a special case.
         */
        QName typeName = ted.getDefinition().getName();
        if ("http://www.opengis.net/citygml/appearance/1.0".equals(typeName.getNamespaceURI())
                && "AppearanceType".equals(typeName.getLocalPart())) {
            // create a dummy XML element
            elements = new XmlElements();
            elements.addElement(
                    new XmlElement(new QName("http://www.opengis.net/citygml/appearance/1.0", "Appearance"),
                            ted.getDefinition(), null));
        } else
            // XXX dirty hack end
            return null;
    }

    // XXX which elements should be used?
    // for now use all elements
    StringBuilder select = new StringBuilder();
    boolean first = true;
    for (XmlElement element : elements.getElements()) {
        if (first) {
            first = false;
        } else {
            select.append(" | ");
        }

        select.append(context);
        select.append('/');
        String ns = element.getName().getNamespaceURI();
        if (ns != null && !ns.isEmpty()) {
            String prefix = namespaces.getPrefix(ns);
            if (prefix != null && !prefix.isEmpty()) {
                select.append(prefix);
                select.append(':');
            }
        }
        select.append(element.getName().getLocalPart());
    }

    // filter
    if (ted.getFilter() != null) {
        String filterxpath = FilterToXPath.toXPath(ted.getDefinition(), namespaces, ted.getFilter());

        if (filterxpath != null && !filterxpath.isEmpty()) {
            select.insert(0, '(');
            select.append(")[");
            select.append(StringEscapeUtils.escapeXml(filterxpath));
            select.append(']');
        }
    }

    return select.toString();
}

From source file:net.orpiske.dcd.dispatcher.impl.WebServicesDispatcher.java

public WebServicesDispatcher() {
    factory = new JaxWsProxyFactoryBean();

    /*//  www. java  2s . c om
     * Setup logging goods
     */
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());

    /*
     * Sets the service class
     */
    factory.setServiceClass(LoadService.class);

    /*
     * Target URL
     */
    String endpoint = config.getString("broker.ws.endpoint", "http://localhost:8001/mdm/broker/loadservice");

    factory.setAddress(endpoint);
    factory.setWsdlURL("classpath:/wsdl/load/v1/loadservice.wsdl");
    factory.setServiceName(new QName("http://www.orpiske.net/exchange/loadservice/v1", "loadService"));

    servicePort = (LoadService) factory.create();
}

From source file:fi.vrk.xroad.catalog.lister.WsdlCdataInterceptor.java

@Override
public boolean handleResponse(MessageContext messageContext, Object o) throws Exception {

    WebServiceMessage response = messageContext.getResponse();

    SaajSoapMessage saajSoapMessage = (SaajSoapMessage) response;
    SOAPMessage soapMessage = saajSoapMessage.getSaajMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    SOAPBody body = envelope.getBody();
    Iterator responses = body// w w w . j a  va  2  s  . c o m
            .getChildElements(new QName("http://xroad.vrk.fi/xroad-catalog-lister", "GetWsdlResponse"));
    while (responses.hasNext()) {
        Node wsdlResponse = (Node) responses.next();
        NodeList children = wsdlResponse.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if (child.getLocalName().equals("wsdl")) {
                CDATASection cdat = soapPart.createCDATASection(child.getFirstChild().getNodeValue());
                child.removeChild(child.getFirstChild());
                child.appendChild(cdat);
            }
        }
    }
    return true;
}

From source file:net.bpelunit.framework.control.util.BPELUnitUtil.java

/**
 * Creates a new, generic SOAP fault to be used when something goes wrong in a partner track and
 * other tracks must be notified.//from  w ww .j  av  a  2  s  .  co m
 * 
 * @return
 */
public static SOAPMessage generateGenericSOAPFault() {

    try {
        MessageFactory mFactory = MessageFactory.newInstance();
        SOAPMessage message = mFactory.createMessage();
        SOAPBody body = message.getSOAPBody();
        SOAPFault fault = body.addFault(BPELUnitConstants.SOAP_FAULT_CODE_CLIENT,
                BPELUnitConstants.SOAP_FAULT_DESCRIPTION);

        Detail detail = fault.addDetail();
        DetailEntry entry = detail
                .addDetailEntry(new QName("http://www.bpelunit.org/framework/error", "BPELUnitFault"));
        entry.addTextNode(
                "The BPELUnit test framework has detected a test failure or error. This test case is aborted.");

        return message;

    } catch (Exception e) {
        return null;
    }
}

From source file:eu.domibus.ebms3.sender.MSHDispatcher.java

public SOAPMessage dispatch(final SOAPMessage soapMessage, final String pModeKey) throws EbMS3Exception {

    final QName serviceName = new QName("http://domibus.eu", "msh-dispatch-service");
    final QName portName = new QName("http://domibus.eu", "msh-dispatch");
    final javax.xml.ws.Service service = javax.xml.ws.Service.create(serviceName);
    final String endpoint = pModeProvider.getReceiverParty(pModeKey).getEndpoint();
    service.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, endpoint);
    Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class,
            javax.xml.ws.Service.Mode.MESSAGE);

    Policy policy = policyFactory
            .parsePolicy(pModeProvider.getLegConfiguration(pModeKey).getSecurity().getPolicy());
    LegConfiguration legConfiguration = pModeProvider.getLegConfiguration(pModeKey);
    dispatch.getRequestContext().put(PolicyConstants.POLICY_OVERRIDE, policy);
    dispatch.getRequestContext().put(ASYMMETRIC_SIG_ALGO_PROPERTY,
            legConfiguration.getSecurity().getSignatureMethod().getAlgorithm());
    dispatch.getRequestContext().put(PMODE_KEY_CONTEXT_PROPERTY, pModeKey);

    TLSClientParameters params = tlsReader.getTlsClientParameters();
    if (params != null && endpoint.startsWith("https://")) {
        Client client = ((DispatchImpl<SOAPMessage>) dispatch).getClient();
        HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
        httpConduit.setTlsClientParameters(params);
    }//from  w  w w.j a v  a2s .  c o m
    SOAPMessage result;
    try {
        result = dispatch.invoke(soapMessage);
    } catch (WebServiceException e) {
        throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0005, null,
                "error dispatching message to " + endpoint, e, MSHRole.SENDING);
    }
    return result;
}

From source file:org.apache.servicemix.jms.JmsSpringJcaTest.java

public void testInOut() throws Exception {
    TransactionManager tm = (TransactionManager) getBean("transactionManager");
    tm.begin();//  w  w  w. j a va2s.  c  om
    InOut me = client.createInOutExchange();
    me.setService(new QName("http://test", "MyProviderService"));
    me.getInMessage().setContent(new StringSource("<echo xmlns='http://test'><echoin0>world</echoin0></echo>"));
    client.send(me);
    tm.commit();
    me = (InOut) client.receive();
    assertEquals(ExchangeStatus.ERROR, me.getStatus());
    assertNotNull(me.getError());
    assertTrue(me.getError() instanceof UnsupportedOperationException);
}

From source file:eu.esdihumboldt.hale.common.instance.orient.internal.ONamespaceMap.java

/**
 * Decode a name based on the runtime namespace map.
 * //from   www . j  a v  a 2s  .  co  m
 * @param name the encoded name
 * @return the decoded qualified name
 * @throws DecoderException of decoding the local part of the name fails
 */
public static QName decode(String name) throws DecoderException {
    int pos = name.indexOf('_'); // find first underscore
    String local;
    String ns = XMLConstants.NULL_NS_URI;
    if (pos < 0) {
        local = ONameUtil.decodeName(name);
    } else {
        ns = IDS.getObject(name.substring(0, pos));
        local = ONameUtil.decodeName(name.substring(pos + 1));
    }
    return new QName(ns, local);
}