Example usage for javax.xml.stream XMLStreamWriter writeStartElement

List of usage examples for javax.xml.stream XMLStreamWriter writeStartElement

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeStartElement.

Prototype

public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException;

Source Link

Document

Writes a start tag to the output

Usage

From source file:nl.nn.adapterframework.soap.Wsdl.java

/**
 * Outputs a 'documentation' section of the WSDL
 *//*from  w  w  w.j a v  a 2 s .c  om*/
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

/**
 * Output the 'types' section of the WSDL
 * @param w//from  w w w . j a v  a  2s . c  o  m
 * @throws XMLStreamException
 * @throws IOException
 */
protected void types(XMLStreamWriter w) throws XMLStreamException, IOException, ConfigurationException {
    w.writeStartElement(WSDL_NAMESPACE, "types");
    if (isUseIncludes()) {
        SchemaUtils.mergeRootXsdsGroupedByNamespaceToSchemasWithIncludes(
                SchemaUtils.getXsdsGroupedByNamespace(rootXsds, true), w);
    } else {
        SchemaUtils.mergeXsdsGroupedByNamespaceToSchemasWithoutIncludes(
                pipeLine.getAdapter().getConfiguration().getClassLoader(), xsdsGroupedByNamespace, w);
    }
    w.writeEndElement();
}

From source file:nl.nn.adapterframework.soap.Wsdl.java

protected void message(XMLStreamWriter w, String root, Collection<QName> parts)
        throws XMLStreamException, IOException {
    if (!parts.isEmpty()) {
        w.writeStartElement(WSDL_NAMESPACE, "message");
        w.writeAttribute("name", "Message_" + root);
        {/*w  ww .  j av  a2s .c om*/
            for (QName part : parts) {
                w.writeEmptyElement(WSDL_NAMESPACE, "part");
                w.writeAttribute("name", "Part_" + part.getLocalPart());
                String type = part.getPrefix() + ":" + part.getLocalPart();
                w.writeAttribute("element", type);
            }
        }
        w.writeEndElement();
    }
}

From source file:nl.nn.adapterframework.soap.Wsdl.java

protected void portType(XMLStreamWriter w) throws XMLStreamException, IOException {
    w.writeStartElement(WSDL_NAMESPACE, "portType");
    w.writeAttribute("name", "PortType_" + getName());
    {/*from  w  w  w .jav  a  2  s  .  c  om*/
        for (IListener listener : WsdlUtils.getListeners(pipeLine.getAdapter())) {
            if (listener instanceof WebServiceListener || listener instanceof JmsListener) {
                w.writeStartElement(WSDL_NAMESPACE, "operation");
                w.writeAttribute("name", "Operation_" + WsdlUtils.getNCName(getSoapAction(listener)));
                {
                    if (StringUtils.isNotEmpty(inputRoot)) {
                        w.writeEmptyElement(WSDL_NAMESPACE, "input");
                        w.writeAttribute("message", getTargetNamespacePrefix() + ":" + "Message_" + inputRoot);
                    }
                    if (StringUtils.isNotEmpty(outputRoot)) {
                        w.writeEmptyElement(WSDL_NAMESPACE, "output");
                        w.writeAttribute("message", getTargetNamespacePrefix() + ":" + "Message_" + outputRoot);
                    }
                }
                w.writeEndElement();
            }
        }
    }
    w.writeEndElement();
}

From source file:nl.nn.adapterframework.soap.Wsdl.java

protected void httpBinding(XMLStreamWriter w, String namePrefix)
        throws XMLStreamException, IOException, ConfigurationException {
    w.writeStartElement(WSDL_NAMESPACE, "binding");
    w.writeAttribute("name", namePrefix + "Binding_" + WsdlUtils.getNCName(getName()));
    w.writeAttribute("type", getTargetNamespacePrefix() + ":" + "PortType_" + getName());
    {//from  w ww. j a  v  a  2  s.c  o m
        w.writeEmptyElement(soapNamespace, "binding");
        w.writeAttribute("transport", SOAP_HTTP_NAMESPACE);
        w.writeAttribute("style", "document");
        for (IListener listener : WsdlUtils.getListeners(pipeLine.getAdapter())) {
            if (listener instanceof WebServiceListener) {
                writeSoapOperation(w, listener);
            }
        }
    }
    w.writeEndElement();
}

From source file:nl.nn.adapterframework.soap.Wsdl.java

protected void writeSoapOperation(XMLStreamWriter w, IListener listener)
        throws XMLStreamException, IOException, ConfigurationException {
    w.writeStartElement(WSDL_NAMESPACE, "operation");
    w.writeAttribute("name", "Operation_" + WsdlUtils.getNCName(getSoapAction(listener)));
    {/*www  .  j  a v  a  2  s .c o m*/
        w.writeEmptyElement(soapNamespace, "operation");
        w.writeAttribute("style", "document");
        w.writeAttribute("soapAction", getSoapAction(listener));
        w.writeStartElement(WSDL_NAMESPACE, "input");
        {
            writeSoapHeader(w, inputRoot, inputHeaderElement, inputHeaderIsOptional);
            writeSoapBody(w, inputBodyElement);
        }
        w.writeEndElement();
        if (outputValidator != null) {
            w.writeStartElement(WSDL_NAMESPACE, "output");
            {
                writeSoapHeader(w, outputRoot, outputHeaderElement, outputHeaderIsOptional);
                writeSoapBody(w, outputBodyElement);
            }
            w.writeEndElement();
        }
    }
    w.writeEndElement();
}

From source file:nl.nn.adapterframework.soap.Wsdl.java

protected void jmsBinding(XMLStreamWriter w, String namePrefix)
        throws XMLStreamException, IOException, ConfigurationException {
    w.writeStartElement(WSDL_NAMESPACE, "binding");
    w.writeAttribute("name", namePrefix + "Binding_" + WsdlUtils.getNCName(getName()));
    w.writeAttribute("type", getTargetNamespacePrefix() + ":" + "PortType_" + getName());
    {//from w  w  w .  ja  va  2  s.  co m
        w.writeEmptyElement(soapNamespace, "binding");
        w.writeAttribute("style", "document");
        if (esbSoap) {
            w.writeAttribute("transport", ESB_SOAP_JMS_NAMESPACE);
            w.writeEmptyElement(ESB_SOAP_JMS_NAMESPACE, "binding");
            w.writeAttribute("messageFormat", "Text");
            for (IListener listener : WsdlUtils.getListeners(pipeLine.getAdapter())) {
                if (listener instanceof JmsListener) {
                    writeSoapOperation(w, listener);
                }
            }
        } else {
            w.writeAttribute("transport", SOAP_JMS_NAMESPACE);
        }
    }
    w.writeEndElement();
}

From source file:nl.nn.adapterframework.soap.Wsdl.java

protected void httpService(XMLStreamWriter w, String servlet, String namePrefix) throws XMLStreamException {
    w.writeStartElement(WSDL_NAMESPACE, "service");
    w.writeAttribute("name", "Service_" + WsdlUtils.getNCName(getName()));
    {//from  www.ja  va  2  s  .  c o  m
        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");
            w.writeAttribute("location", getLocation(servlet));
        }
        w.writeEndElement();
    }
    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()));
    {//w  ww. j  a  va2 s.  c  om
        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");
    {/*from   www  .j  av a 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();
}