List of usage examples for javax.xml.stream XMLStreamWriter writeCharacters
public void writeCharacters(String text) throws XMLStreamException;
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.SchemaGraph2XMI.java
/** * Creates the default values.//from www. ja v a 2 s . co m * * @param writer * {@link XMLStreamWriter} of the current XMI file * @param defaultValue * {@link String} the default value of the current * {@link Attribute} * @param id * {@link String} the id of the current {@link Attribute} * @param domain * {@link Domain} the type of the current {@link Attribute} * @throws XMLStreamException */ private void createDefaultValue(XMLStreamWriter writer, String defaultValue, String id, Domain domain) throws XMLStreamException { // start defaultValue if (domain instanceof LongDomain || domain instanceof EnumDomain) { writer.writeEmptyElement(XMIConstants4SchemaGraph2XMI.TAG_DEFAULTVALUE); } else { writer.writeStartElement(XMIConstants4SchemaGraph2XMI.TAG_DEFAULTVALUE); } if (domain instanceof BooleanDomain) { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, XMIConstants4SchemaGraph2XMI.TYPE_VALUE_LITERALBOOLEAN); } else if (domain instanceof IntegerDomain || domain instanceof LongDomain) { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, XMIConstants4SchemaGraph2XMI.TYPE_VALUE_LITERALINTEGER); } else if (domain instanceof EnumDomain) { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, XMIConstants4SchemaGraph2XMI.TYPE_VALUE_INSTANCEVALUE); } else { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, XMIConstants4SchemaGraph2XMI.TYPE_VALUE_OPAQUEEXPRESSION); } writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_ID, id + "_defaultValue"); if (domain instanceof BooleanDomain || domain instanceof IntegerDomain || domain instanceof LongDomain || domain instanceof EnumDomain) { if (domain instanceof BooleanDomain) { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.ATTRIBUTE_VALUE, defaultValue.equals("t") ? "true" : "false"); } else if (domain instanceof EnumDomain) { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.ATTRIBUTE_NAME, defaultValue); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, domain.get_qualifiedName()); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.DEFAULTVALUE_ATTRIBUTE_INSTANCE, domain.get_qualifiedName() + "_" + defaultValue); } else { writer.writeAttribute(XMIConstants4SchemaGraph2XMI.ATTRIBUTE_VALUE, defaultValue); } // create type if (domain instanceof BooleanDomain || domain instanceof IntegerDomain) { createType(writer, domain); } } else { if (domain instanceof StringDomain) { // create type createType(writer, domain); } else { // there has to be created an entry for the current domain in // the package primitiveTypes writer.writeAttribute(XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, domain.get_qualifiedName().replaceAll("\\s", "").replaceAll("<", "_").replaceAll(">", "_")); } // start body writer.writeStartElement(XMIConstants4SchemaGraph2XMI.TAG_BODY); writer.writeCharacters(defaultValue); // end body writer.writeEndElement(); } if (!(domain instanceof LongDomain || domain instanceof EnumDomain)) { // end defaultValue writer.writeEndElement(); } }
From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java
private void sparqlQuery(String sparql, TripleStore ts, Map<String, String[]> params, String pathInfo, HttpServletResponse res) throws Exception { if (sparql == null) { Map err = error(SC_BAD_REQUEST, "No query specified.", null); output(err, params, pathInfo, res); return;/*from w w w. j ava 2 s. com*/ } else { log.info("sparql: " + sparql); } // sparql query BindingIterator objs = ts.sparqlSelect(sparql); // start output String sparqlNS = "http://www.w3.org/2005/sparql-results#"; res.setContentType("application/sparql-results+xml"); OutputStream out = res.getOutputStream(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter stream = factory.createXMLStreamWriter(out); stream.setDefaultNamespace(sparqlNS); stream.writeStartDocument(); stream.writeStartElement("sparql"); // output bindings boolean headerWritten = false; while (objs.hasNext()) { Map<String, String> binding = objs.nextBinding(); // write header on first binding if (!headerWritten) { Iterator<String> it = binding.keySet().iterator(); stream.writeStartElement("head"); while (it.hasNext()) { String k = it.next(); stream.writeStartElement("variable"); stream.writeAttribute("name", k); stream.writeEndElement(); } stream.writeEndElement(); stream.writeStartElement("results"); // ordered='false' distinct='false' headerWritten = true; } stream.writeStartElement("result"); Iterator<String> it = binding.keySet().iterator(); while (it.hasNext()) { String k = it.next(); String v = binding.get(k); stream.writeStartElement("binding"); stream.writeAttribute("name", k); String type = null; if (v.startsWith("\"") && v.endsWith("\"")) { type = "literal"; v = v.substring(1, v.length() - 1); } else if (v.startsWith("_:")) { type = "bnode"; v = v.substring(2); } else { type = "uri"; } stream.writeStartElement(type); stream.writeCharacters(v); stream.writeEndElement(); stream.writeEndElement(); } stream.writeEndElement(); } // finish output stream.writeEndElement(); stream.writeEndDocument(); stream.flush(); stream.close(); }
From source file:ca.uhn.fhir.parser.XmlParser.java
private void encodeResourceToXmlStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, boolean theContainedResource, IIdType theResourceId) throws XMLStreamException { if (!theContainedResource) { super.containResourcesForEncoding(theResource); }/*from w w w . j av a 2s .com*/ RuntimeResourceDefinition resDef = myContext.getResourceDefinition(theResource); if (resDef == null) { throw new ConfigurationException("Unknown resource type: " + theResource.getClass()); } theEventWriter.writeStartElement(resDef.getName()); theEventWriter.writeDefaultNamespace(FHIR_NS); if (theResource instanceof IAnyResource) { // HL7.org Structures if (theResourceId != null) { writeCommentsPre(theEventWriter, theResourceId); writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart()); writeCommentsPost(theEventWriter, theResourceId); } encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef)); } else { if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) { // DSTU2+ IResource resource = (IResource) theResource; if (theResourceId != null) { writeCommentsPre(theEventWriter, theResourceId); writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart()); writeCommentsPost(theEventWriter, theResourceId); } InstantDt updated = (InstantDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED); IdDt resourceId = resource.getId(); String versionIdPart = resourceId.getVersionIdPart(); if (isBlank(versionIdPart)) { versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource); } List<BaseCodingDt> securityLabels = extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.SECURITY_LABELS); List<? extends IIdType> profiles = extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.PROFILES); profiles = super.getProfileTagsForEncoding(resource, profiles); TagList tags = getMetaTagsForEncoding((resource)); if (super.shouldEncodeResourceMeta(resource) && ElementUtil.isEmpty(versionIdPart, updated, securityLabels, tags, profiles) == false) { theEventWriter.writeStartElement("meta"); writeOptionalTagWithValue(theEventWriter, "versionId", versionIdPart); if (updated != null) { writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString()); } for (IIdType profile : profiles) { theEventWriter.writeStartElement("profile"); theEventWriter.writeAttribute("value", profile.getValue()); theEventWriter.writeEndElement(); } for (BaseCodingDt securityLabel : securityLabels) { theEventWriter.writeStartElement("security"); encodeCompositeElementToStreamWriter(resource, securityLabel, theEventWriter, theContainedResource, null); theEventWriter.writeEndElement(); } if (tags != null) { for (Tag tag : tags) { if (tag.isEmpty()) { continue; } theEventWriter.writeStartElement("tag"); writeOptionalTagWithValue(theEventWriter, "system", tag.getScheme()); writeOptionalTagWithValue(theEventWriter, "code", tag.getTerm()); writeOptionalTagWithValue(theEventWriter, "display", tag.getLabel()); theEventWriter.writeEndElement(); } } theEventWriter.writeEndElement(); } if (theResource instanceof IBaseBinary) { IBaseBinary bin = (IBaseBinary) theResource; writeOptionalTagWithValue(theEventWriter, "contentType", bin.getContentType()); writeOptionalTagWithValue(theEventWriter, "content", bin.getContentAsBase64()); } else { encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef)); } } else { // DSTU1 if (theResourceId != null && theContainedResource && theResourceId.hasIdPart()) { theEventWriter.writeAttribute("id", theResourceId.getIdPart()); } if (theResource instanceof IBaseBinary) { IBaseBinary bin = (IBaseBinary) theResource; if (bin.getContentType() != null) { theEventWriter.writeAttribute("contentType", bin.getContentType()); } theEventWriter.writeCharacters(bin.getContentAsBase64()); } else { encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef)); } } } theEventWriter.writeEndElement(); }
From source file:com.fiorano.openesb.application.application.PortInstance.java
protected void toJXMLString_1(XMLStreamWriter writer, boolean writeSchema) throws XMLStreamException, FioranoException { if (proxyUsed || !StringUtils.isEmpty(proxyURL) || !ANONYMOUS.equals(proxyUser) || !ANONYMOUS.equals(proxyPassword)) { writer.writeStartElement(ELEM_PROXY); {/* w ww. j a va2 s. c o m*/ if (proxyUsed) writer.writeAttribute(ATTR_PROXY_USED, String.valueOf(proxyUsed)); writeAttribute(writer, ATTR_PROXY_URL, proxyURL); if (!ANONYMOUS.equals(proxyUser) || !ANONYMOUS.equals(proxyPassword)) { writer.writeStartElement(ELEM_AUTHENTICATION); { if (!ANONYMOUS.equals(proxyUser)) writer.writeAttribute(ATTR_PROXY_USER, proxyUser); if (!ANONYMOUS.equals(proxyPassword)) writer.writeAttribute(ATTR_PROXY_PASSWORD, proxyPassword); } writer.writeEndElement(); } } writer.writeEndElement(); } writer.writeStartElement(ELEM_JMS); { writeAttribute(writer, ATTR_CLIENT_ID, clientID); if (!enabled) writer.writeAttribute(ATTR_ENABLED, String.valueOf(enabled)); if (writeSchema || destinationConfigName == null) { writer.writeStartElement(ELEM_DESTINATION); { if (destinationType != getDefaultDestinationType()) writer.writeAttribute(ATTR_DESTINATION_TYPE, String.valueOf(destinationType)); if (specifiedDestinationUsed) writer.writeAttribute(ATTR_SPECIFIED_DESTINATION_USED, String.valueOf(specifiedDestinationUsed)); writeAttribute(writer, ATTR_DESTINATION, destination); if (isDestinationEncrypted) { writer.writeAttribute(IS_DESTINATION_ENCRYPTED, String.valueOf(isDestinationEncrypted)); writer.writeAttribute(DESTINATION_ENCRYPT_ALGO, encryptionAlgorithm); if (encryptionKey == null || encryptionKey.equals("")) writer.writeAttribute(DESTINATION_ENCRYPT_KEY, ""); else writer.writeAttribute(DESTINATION_ENCRYPT_KEY, encryptionKey); writer.writeAttribute(DESTINATION_ALLOW_PADDING_TO_KEY, String.valueOf(allowPaddingToKey)); writer.writeAttribute(DESTINATION_INITIALIZATION_VECTOR, initializationVector); } } writer.writeEndElement(); } else if (destinationConfigName != null) { writer.writeStartElement(ELEM_DESTINATION_CONFIG_NAME); writer.writeAttribute(ATTR_NAME, destinationConfigName); writer.writeEndElement(); } if (!StringUtils.isEmpty(securityManager) || !ANONYMOUS.equals(user) || !ANONYMOUS.equals(password)) { writer.writeStartElement(ELEM_AUTHENTICATION); { writeAttribute(writer, ATTR_SECURITY_MANAGER, securityManager); if (!ANONYMOUS.equals(user)) writer.writeAttribute(ATTR_USER, user); if (!ANONYMOUS.equals(password)) writer.writeAttribute(ATTR_PASSWORD, password); } writer.writeEndElement(); } toJXMLString_2(writer, writeSchema); } writer.writeEndElement(); if ((writeSchema || workflowConfigName == null)) { // We need to write port properties to stream when passing application launch packet to peer writer.writeStartElement(ELEM_WORKFLOW); writer.writeAttribute(ATTR_WORKFLOW_TYPE, String.valueOf(workflow)); writer.writeAttribute(ATTR_WORKFLOW_DATATYPE, String.valueOf(workflowDataType)); writer.writeAttribute(ATTR_CALLOUT_ENABLED, String.valueOf(calloutEnabled)); for (DBCallOutParameter dbCallOutParameter : dbCallOutParameterList) { dbCallOutParameter.toJXMLString(writer); } writer.writeEndElement(); } else if (workflowConfigName != null) { writer.writeStartElement(ELEM_WORKFLOW_CONFIG_NAME); writer.writeAttribute(ATTR_NAME, workflowConfigName); writer.writeEndElement(); } if ((writeSchema || messageFilterConfigName == null) && (isMessageFilterSet)) { writer.writeStartElement(ELEM_MESSAGE_FILTERS); for (Iterator itr = messageFilters.entrySet().iterator(); itr.hasNext();) { Map.Entry entry = (Map.Entry) itr.next(); writer.writeStartElement(ELEM_MESSAGE_FILTER); writer.writeAttribute(ATTR_MESSAGE_FILTER_NAME, (String) entry.getKey()); writer.writeAttribute(ATTR_MESSAGE_FILTER_VALUE, (String) entry.getValue()); writer.writeEndElement(); } writer.writeEndElement(); } else if (messageFilterConfigName != null) { writer.writeStartElement(ELEM_MESSAGE_FILTER_CONFIG_NAME); writer.writeAttribute(ATTR_NAME, messageFilterConfigName); writer.writeEndElement(); } if (!appContextAction.equalsIgnoreCase(NO_ACTION_APP_CONTEXT)) { writer.writeStartElement(ELEM_APP_CONTEXT_ACTION); writer.writeCharacters(appContextAction); writer.writeEndElement(); } toJXMLString_3(writer, writeSchema); }
From source file:nl.armatiek.xslweb.serializer.RequestSerializer.java
private void dataElement(XMLStreamWriter xsw, String uri, String localName, String text) throws XMLStreamException { if (text == null) { return;//from www. ja v a 2s . co m } if (text.equals("")) { xsw.writeEmptyElement(uri, localName); } else { xsw.writeStartElement(uri, localName); xsw.writeCharacters(text); xsw.writeEndElement(); } }
From source file:nl.nn.adapterframework.extensions.svn.ScanTibcoSolutionPipe.java
private void addFileContent(XMLStreamWriter xmlStreamWriter, String urlString, String type) throws XMLStreamException { xmlStreamWriter.writeStartElement("content"); xmlStreamWriter.writeAttribute("type", type); String content;//from w w w. j a v a 2 s . c o m try { content = getHtml(urlString); } catch (Exception e) { error(xmlStreamWriter, "error occured during getting file content", e, true); content = null; } if (content != null) { Vector<String> warnMessage = new Vector<String>(); try { if (type.equals("jmsDest") || type.equals("jmsDestConf")) { // AMX - receive (for jmsInboundDest) Collection<String> c1 = XmlUtils.evaluateXPathNodeSet(content, "namedResource/@name"); if (c1 != null && c1.size() > 0) { if (c1.size() > 1) { warnMessage.add("more then one resourceName found"); } String resourceName = (String) c1.iterator().next(); xmlStreamWriter.writeStartElement("resourceName"); xmlStreamWriter.writeCharacters(resourceName); xmlStreamWriter.writeEndElement(); } else { warnMessage.add("no resourceName found"); } Collection<String> c2 = XmlUtils.evaluateXPathNodeSet(content, "namedResource/configuration/@jndiName"); if (c2 != null && c2.size() > 0) { if (c2.size() > 1) { warnMessage.add("more then one resourceJndiName found"); } String resourceJndiName = (String) c2.iterator().next(); xmlStreamWriter.writeStartElement("resourceJndiName"); xmlStreamWriter.writeCharacters(resourceJndiName); xmlStreamWriter.writeEndElement(); } else { warnMessage.add("no resourceJndiName found"); } } else if (type.equals("composite")) { // AMX - receive Collection<String> c1 = XmlUtils.evaluateXPathNodeSet(content, "composite/service/bindingAdjunct/property[@name='JmsInboundDestinationConfig']/@simpleValue"); if (c1 != null && c1.size() > 0) { for (Iterator<String> c1it = c1.iterator(); c1it.hasNext();) { xmlStreamWriter.writeStartElement("jmsInboundDest"); xmlStreamWriter.writeCharacters(c1it.next()); xmlStreamWriter.writeEndElement(); } } else { warnMessage.add("no jmsInboundDest found"); } // AMX - send Collection<String> c2 = XmlUtils.evaluateXPathNodeSet(content, "composite/reference/interface.wsdl/@wsdlLocation"); if (c2 != null && c2.size() > 0) { for (Iterator<String> c2it = c2.iterator(); c2it.hasNext();) { String itn = c2it.next(); String wsdl = null; try { URL url = new URL(urlString); URL wsdlUrl = new URL(url, itn); wsdl = getHtml(wsdlUrl.toString()); } catch (Exception e) { error(xmlStreamWriter, "error occured during getting wsdl file content", e, true); wsdl = null; } if (wsdl != null) { Collection<String> c3 = XmlUtils.evaluateXPathNodeSet(wsdl, // "definitions/service/port/targetAddress", // "concat(.,';',../../@name)"); "definitions/service/port/targetAddress"); if (c3 != null && c3.size() > 0) { for (Iterator<String> c3it = c3.iterator(); c3it.hasNext();) { xmlStreamWriter.writeStartElement("targetAddr"); xmlStreamWriter.writeCharacters(c3it.next()); xmlStreamWriter.writeEndElement(); } } else { warnMessage.add("no targetAddr found"); } } else { warnMessage.add("wsdl [" + itn + "] not found"); } } } else { warnMessage.add("no wsdlLocation found"); } } else if (type.equals("process")) { // BW - receive Double d1 = XmlUtils.evaluateXPathNumber(content, "count(ProcessDefinition/starter[type='com.tibco.plugin.soap.SOAPEventSource']/config)"); if (d1 > 0) { Collection<String> c1 = XmlUtils.evaluateXPathNodeSet(content, "ProcessDefinition/starter[type='com.tibco.plugin.soap.SOAPEventSource']/config/sharedChannels/jmsChannel/JMSTo"); if (c1 != null && c1.size() > 0) { for (Iterator<String> c1it = c1.iterator(); c1it.hasNext();) { xmlStreamWriter.writeStartElement("jmsTo"); xmlStreamWriter.writeAttribute("type", "soapEventSource"); xmlStreamWriter.writeCharacters(c1it.next()); xmlStreamWriter.writeEndElement(); } } else { warnMessage.add("no jmsTo found for soapEventSource"); } } else { warnMessage.add("no soapEventSource found"); } // BW - send Double d2 = XmlUtils.evaluateXPathNumber(content, "count(ProcessDefinition/activity[type='com.tibco.plugin.soap.SOAPSendReceiveActivity']/config)"); if (d2 > 0) { Collection<String> c2 = XmlUtils.evaluateXPathNodeSet(content, "ProcessDefinition/activity[type='com.tibco.plugin.soap.SOAPSendReceiveActivity']/config/sharedChannels/jmsChannel/JMSTo"); if (c2 != null && c2.size() > 0) { for (Iterator<String> c2it = c2.iterator(); c2it.hasNext();) { xmlStreamWriter.writeStartElement("jmsTo"); xmlStreamWriter.writeAttribute("type", "soapSendReceiveActivity"); xmlStreamWriter.writeCharacters(c2it.next()); xmlStreamWriter.writeEndElement(); } } else { warnMessage.add("no jmsTo found for soapSendReceiveActivity"); } } else { warnMessage.add("no soapSendReceiveActivity found"); } } else if (type.equals("substVar")) { String path = StringUtils .substringBeforeLast(StringUtils.substringAfterLast(urlString, "/defaultVars/"), "/"); Map<String, String> m1 = XmlUtils.evaluateXPathNodeSet(content, "repository/globalVariables/globalVariable", "name", "value"); if (m1 != null && m1.size() > 0) { for (Iterator<String> m1it = m1.keySet().iterator(); m1it.hasNext();) { Object key = m1it.next(); Object value = m1.get(key); xmlStreamWriter.writeStartElement("globalVariable"); xmlStreamWriter.writeAttribute("name", (String) key); xmlStreamWriter.writeAttribute("ref", "%%" + path + "/" + key + "%%"); xmlStreamWriter.writeCharacters((String) value); xmlStreamWriter.writeEndElement(); } } else { warnMessage.add("no globalVariable found"); } /* * } else { content = XmlUtils.removeNamespaces(content); * xmlStreamWriter.writeCharacters(content); */ } } catch (Exception e) { error(xmlStreamWriter, "error occured during processing " + type + " file", e, true); } if (warnMessage.size() > 0) { xmlStreamWriter.writeStartElement("warnMessages"); for (int i = 0; i < warnMessage.size(); i++) { xmlStreamWriter.writeStartElement("warnMessage"); xmlStreamWriter.writeCharacters(warnMessage.elementAt(i)); xmlStreamWriter.writeEndElement(); } xmlStreamWriter.writeEndElement(); } } xmlStreamWriter.writeEndElement(); }
From source file:nl.nn.adapterframework.extensions.svn.ScanTibcoSolutionPipe.java
private void error(XMLStreamWriter xmlStreamWriter, String msg, Throwable t, boolean printStackTrace) throws XMLStreamException { log.warn(msg, t);//from w ww.j av a2 s.co m xmlStreamWriter.writeStartElement("errorMessage"); String errorMsg; if (printStackTrace) { StringWriter trace = new StringWriter(); t.printStackTrace(new PrintWriter(trace)); errorMsg = msg + ": " + trace; } else { errorMsg = msg + ": " + t.getMessage(); } xmlStreamWriter.writeCharacters(errorMsg); xmlStreamWriter.writeEndElement(); }
From source file:nl.nn.adapterframework.soap.Wsdl.java
/** * Outputs a 'documentation' section of the WSDL *///from w w w . j a va2s . c o m protected void documentation(XMLStreamWriter w) throws XMLStreamException { if (documentation != null) { w.writeStartElement(WSDL_NAMESPACE, "documentation"); w.writeCharacters(documentation); w.writeEndElement(); } }
From source file:nl.nn.adapterframework.soap.Wsdl.java
protected void jmsService(XMLStreamWriter w, JmsListener listener, String namePrefix) throws XMLStreamException, NamingException { w.writeStartElement(WSDL_NAMESPACE, "service"); w.writeAttribute("name", "Service_" + WsdlUtils.getNCName(getName())); {/*from w w w . jav a2s .c o m*/ if (!esbSoap) { // Per example of https://docs.jboss.org/author/display/JBWS/SOAP+over+JMS w.writeStartElement(SOAP_JMS_NAMESPACE, "jndiConnectionFactoryName"); w.writeCharacters(listener.getQueueConnectionFactoryName()); } w.writeStartElement(WSDL_NAMESPACE, "port"); w.writeAttribute("name", namePrefix + "Port_" + WsdlUtils.getNCName(getName())); w.writeAttribute("binding", getTargetNamespacePrefix() + ":" + namePrefix + "Binding_" + WsdlUtils.getNCName(getName())); { w.writeEmptyElement(soapNamespace, "address"); String destinationName = listener.getDestinationName(); if (destinationName != null) { w.writeAttribute("location", getLocation(destinationName)); } if (esbSoap) { writeEsbSoapJndiContext(w, listener); w.writeStartElement(ESB_SOAP_JMS_NAMESPACE, "connectionFactory"); { w.writeCharacters("externalJndiName-for-" + listener.getQueueConnectionFactoryName() + "-on-" + AppConstants.getInstance().getResolvedProperty("otap.stage")); w.writeEndElement(); } w.writeStartElement(ESB_SOAP_JMS_NAMESPACE, "targetAddress"); { w.writeAttribute("destination", listener.getDestinationType().toLowerCase()); String queueName = listener.getPhysicalDestinationShortName(); if (queueName == null) { queueName = "queueName-for-" + listener.getDestinationName() + "-on-" + AppConstants.getInstance().getResolvedProperty("otap.stage"); } w.writeCharacters(queueName); w.writeEndElement(); } } } w.writeEndElement(); } w.writeEndElement(); }
From source file:nl.nn.adapterframework.soap.Wsdl.java
protected void writeEsbSoapJndiContext(XMLStreamWriter w, JmsListener listener) throws XMLStreamException, NamingException { w.writeStartElement(ESB_SOAP_JNDI_NAMESPACE, "context"); {//w w w . ja va 2 s . c o m w.writeStartElement(ESB_SOAP_JNDI_NAMESPACE, "property"); { w.writeAttribute("name", "java.naming.factory.initial"); w.writeAttribute("type", "java.lang.String"); w.writeCharacters("com.tibco.tibjms.naming.TibjmsInitialContextFactory"); w.writeEndElement(); } w.writeStartElement(ESB_SOAP_JNDI_NAMESPACE, "property"); { w.writeAttribute("name", "java.naming.provider.url"); w.writeAttribute("type", "java.lang.String"); String qcf = listener.getQueueConnectionFactoryName(); if (StringUtils.isEmpty(qcf)) { warn("Attribute queueConnectionFactoryName empty for listener '" + listener.getName() + "'"); } else { try { qcf = URLEncoder.encode(qcf, "UTF-8"); } catch (UnsupportedEncodingException e) { warn("Could not encode queueConnectionFactoryName for listener '" + listener.getName() + "'"); } } String stage = AppConstants.getInstance().getResolvedProperty("otap.stage"); if (StringUtils.isEmpty(stage)) { warn("Property otap.stage empty"); } else { try { stage = URLEncoder.encode(stage, "UTF-8"); } catch (UnsupportedEncodingException e) { warn("Could not encode property otap.stage"); } } w.writeCharacters("tibjmsnaming://host-for-" + qcf + "-on-" + stage + ":37222"); w.writeEndElement(); } w.writeStartElement(ESB_SOAP_JNDI_NAMESPACE, "property"); { w.writeAttribute("name", "java.naming.factory.object"); w.writeAttribute("type", "java.lang.String"); w.writeCharacters("com.tibco.tibjms.custom.CustomObjectFactory"); w.writeEndElement(); } } w.writeEndElement(); }