List of usage examples for javax.xml.namespace QName QName
public QName(String namespaceURI, String localPart, String prefix)
QName
constructor specifying the Namespace URI, local part and prefix.
If the Namespace URI is null
, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .
From source file:Main.java
public static QName getQName(String uri, String localName, String qName) { return new QName(uri, localName, qName); }
From source file:Main.java
/** * @param key Local element name.//from w w w . j ava2 s . com */ public static QName createQNameWithCustomNamespace(String key) { return new QName(CUSTOM_NAMESPACE_URI, key, CUSTOM_NAMESPACE_PREFIX); }
From source file:Main.java
public static QName getQNameFromString(Element element, String qnameAsString) { if (qnameAsString == null || element == null) { return null; }// w w w . j a v a2s .c o m int colonIndex = qnameAsString.indexOf(":"); String prefix = qnameAsString.substring(0, colonIndex); String localName = qnameAsString.substring(colonIndex + 1); String ns = getNamespaceURI(element, prefix); return new QName(ns, localName, prefix); }
From source file:Main.java
public static QName getQNameFromString(final Element element, final String qnameAsString) { if (qnameAsString == null || element == null) { return null; }//from w w w . j ava 2 s . c om final int colonIndex = qnameAsString.indexOf(':'); final String prefix = qnameAsString.substring(0, colonIndex); final String localName = qnameAsString.substring(colonIndex + 1); final String ns = getNamespaceURI(element, prefix); return new QName(ns, localName, prefix); }
From source file:io.milton.httpclient.RespUtils.java
public static QName davName(String localName) { return new QName(NS_DAV.getURI(), localName, NS_DAV.getPrefix()); }
From source file:Main.java
/** * returns the matching Extension provider for a given QName/namespaceURI+prefix+localName * combination/*from www. ja v a2 s. co m*/ * * @param extensionMap registered extension Map for the corresponding extension provider * @param namespaceURI binding namespace in xpath expression * @param prefix binding prefix string in xpath expression * @param localName binding localname string in xpath expression * @param <T> Variable/Function Context Provider Type * @return matching Extension provider. returns null if no extension is found for the given * combination */ private static <T> T getMatchingExtensionProvider(Map<QName, T> extensionMap, String namespaceURI, String prefix, String localName) { QName subject; if (localName != null && prefix != null) { subject = new QName(namespaceURI, localName, prefix); } else if (localName != null) { subject = new QName(namespaceURI, localName); } else { //can't resolve xpath extensions - invalid combination return null; } Set<QName> qNames = extensionMap.keySet(); for (QName qName : qNames) { //check for a match for the given combination for QName registered if (subject.equals(qName)) { return extensionMap.get(qName); } } //no match found return null; }
From source file:org.konghao.student.ws.interceptor.LicenseInfoOutHandler.java
public void handleMessage(SoapMessage message) throws Fault { try {//from ww w . j av a2 s .c o m List<Header> hs = message.getHeaders(); QName qn = new QName("http://ws.student.konghao.org", "licenseInfo", "ns"); DataBinding db = new JAXBDataBinding(String.class); Header h = new Header(qn, LoginUserContext.getLoginUser(), db); hs.add(h); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:org.drools.server.CxfSoapClientServerTest.java
@org.junit.Test public void test1() throws Exception { ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext( "classpath:beans-test.xml"); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody(); QName payloadName = new QName("http://soap.jax.drools.org", "execute", "ns1"); body.addBodyElement(payloadName);/*ww w . j a v a 2 s . co m*/ String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += " <insert out-identifier=\"message\">\n"; cmd += " <org.drools.server.Message>\n"; cmd += " <text>Helllo World</text>\n"; cmd += " </org.drools.server.Message>\n"; cmd += " </insert>\n"; cmd += "</batch-execution>\n"; body.addTextNode(cmd); CamelServerApp test = new CamelServerApp(); String response = test.execute(soapMessage, (CamelContext) springContext.getBean("camel-client-ctx")); assertTrue(response.contains("execution-results")); assertTrue(response.contains("echo")); springContext.stop(); }
From source file:org.kie.camel.component.cxf.CxfSoapTest.java
@Test public void test1() throws Exception { SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody(); QName payloadName = new QName("http://soap.jax.drools.org", "execute", "ns1"); body.addBodyElement(payloadName);/*from w ww. j a va 2 s . c o m*/ String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += " <insert out-identifier=\"salaboy\" disconnected=\"true\">\n"; cmd += " <org.kie.pipeline.camel.Person>\n"; cmd += " <name>salaboy</name>\n"; cmd += " <age>27</age>\n"; cmd += " </org.kie.pipeline.camel.Person>\n"; cmd += " </insert>\n"; cmd += " <fire-all-rules/>\n"; cmd += "</batch-execution>\n"; body.addTextNode(cmd); Object object = this.context.createProducerTemplate().requestBody("direct://http", soapMessage); OutputStream out = new ByteArrayOutputStream(); out = new ByteArrayOutputStream(); soapMessage = (SOAPMessage) object; soapMessage.writeTo(out); String response = out.toString(); assertTrue(response.contains("fact-handle identifier=\"salaboy\"")); }
From source file:eu.esdihumboldt.hale.io.wfs.ui.KVPUtil.java
/** * Add typename and namespace parameters for a WFS request to the given URI * builder./* ww w . j a v a2 s .c o m*/ * * @param builder the builder for the WFS request URI * @param selected the type names to include * @param version the targeted WFS version */ public static void addTypeNameParameter(URIBuilder builder, Iterable<QName> selected, WFSVersion version) { // namespaces mapped to prefixes Map<String, String> namespaces = new HashMap<>(); // type names with updated prefix Set<QName> typeNames = new HashSet<>(); for (QName type : selected) { String prefix; if (type.getNamespaceURI() != null && !type.getNamespaceURI().isEmpty()) { prefix = namespaces.get(type.getNamespaceURI()); if (prefix == null) { // no mapping yet for namespace String candidate = type.getPrefix(); prefix = addPrefix(candidate, type.getNamespaceURI(), namespaces); } } else { // default namespace prefix = XMLConstants.DEFAULT_NS_PREFIX; } // add updated type typeNames.add(new QName(type.getNamespaceURI(), type.getLocalPart(), prefix)); } final String paramNamespaces; final String paramTypenames; final String prefixNamespaceDelim; switch (version) { case V1_1_0: paramNamespaces = "NAMESPACE"; paramTypenames = "TYPENAME"; prefixNamespaceDelim = "="; break; case V2_0_0: case V2_0_2: /* * XXX below are the values as defined in the WFS 2 specification. * There have been problems with some GeoServer instances if used in * that manner. */ paramNamespaces = "NAMESPACES"; paramTypenames = "TYPENAMES"; prefixNamespaceDelim = ","; break; default: // fall-back to WFS 1.1 paramNamespaces = "NAMESPACE"; paramTypenames = "TYPENAME"; prefixNamespaceDelim = "="; } // add namespace prefix definitions if (!namespaces.isEmpty()) { builder.addParameter(paramNamespaces, Joiner.on(',') .join(Maps.transformEntries(namespaces, new EntryTransformer<String, String, String>() { @Override public String transformEntry(String namespace, String prefix) { StringBuilder sb = new StringBuilder(); sb.append("xmlns("); sb.append(prefix); sb.append(prefixNamespaceDelim); sb.append(namespace); sb.append(")"); return sb.toString(); } }).values())); } // add type names if (!typeNames.isEmpty()) { builder.addParameter(paramTypenames, Joiner.on(',').join(Iterables.transform(typeNames, new Function<QName, String>() { @Override public String apply(QName typeName) { String prefix = typeName.getPrefix(); if (prefix == null || prefix.isEmpty()) { return typeName.getLocalPart(); } return prefix + ":" + typeName.getLocalPart(); } }))); } }