Class SOAPParser

  • All Implemented Interfaces:
    ParserInterface, VersionInfoInterface, org.xml.sax.ErrorHandler

    public class SOAPParser
    extends XMLParser
    The SOAP Parser reads and writes SOAP XML documents. The Parser converts SOAP XML documents to or from entry objects in a simple, straightforward fashion.
    • Constructor Detail

      • SOAPParser

        public SOAPParser()
        Creates SOAPParser.
    • Method Detail

      • initOutput

        public void initOutput()
                        throws java.lang.Exception
        Initializes the output Document
        Overrides:
        initOutput in class XMLParser
        Throws:
        java.lang.Exception - If could not find output stream.
      • parseRequest

        public Entry parseRequest​(java.lang.Object request)
                           throws java.lang.Exception
        Sets the current input stream and initializes the parser.
        Parameters:
        request - the requested Reader.
        Returns:
        first read entry containing the parsed attributes.
        Throws:
        java.lang.Exception - if I/O error occurs.
      • findNamedElement

        public org.w3c.dom.Node findNamedElement​(org.w3c.dom.NodeList list,
                                                 java.lang.String name)
        Finds node element by given name.
        Parameters:
        list - NodeList to search into.
        name - the name of the searched node.
        Returns:
        first Element node named name.
      • getElementList

        public java.util.Vector<org.w3c.dom.Element> getElementList​(org.w3c.dom.Node parent)
        Return list containing all children of the parent node.
        Parameters:
        parent - the parent Node.
        Returns:
        Vector with all Element children
      • getElement

        public org.w3c.dom.Node getElement​(org.w3c.dom.Node parent,
                                           int index)
        Returns Node object by given index.
        Parameters:
        parent - the parent Node.
        index - the index of the desired Node.
        Returns:
        Node object at index position.
      • getFirstText

        public org.w3c.dom.Node getFirstText​(org.w3c.dom.Node parent)
        Gets the text of the first child of a given Node.
        Parameters:
        parent - the parent Node
        Returns:
        string containing the text value.
      • dumpNodes

        public void dumpNodes​(java.lang.String prefix,
                              org.w3c.dom.NodeList list)
        Prints the contents of the NodeList depending on the types of the .
        Parameters:
        prefix - prefix of the log message.
        list - the NodeList object to be printed.
        See Also:
        printNode(String, Node)
      • printNode

        public void printNode​(java.lang.String prefix,
                              org.w3c.dom.Node n)
        Prints the contents of the Node depending on its type.
        Parameters:
        prefix - prefix of the log message.
        n - the Node to be printed.
      • p

        public void p​(java.lang.String s)
        Writes a message to the log.
        Parameters:
        s - The log message
        See Also:
        ParserImpl.logmsg(String)
      • readEntry

        public Entry readEntry()
                        throws java.lang.Exception
        Reads SOAP XML documents. The attribute SOAP_CALL is set to reflect the first tag following the SOAP-ENV:Body tag. Each tag under the SOAP_CALL tag translates to an attribute in the entry object.
        Specified by:
        readEntry in interface ParserInterface
        Overrides:
        readEntry in class XMLParser
        Returns:
        the entry containing the read attributes.
        Throws:
        java.lang.Exception - if the XML file is invalid or malformed SOAP XML document.
      • findBodyElement

        public org.w3c.dom.Node findBodyElement()
        Finds the SOAP Body element.
        Returns:
        The SOAP Body element
      • writeEntry

        public void writeEntry​(Entry entry)
                        throws java.lang.Exception
        Writes SOAP XML document. The SOAPParser uses attributes from the entry to build the document. The SOAP_CALL attribute is expected to contain the value for the SOAP call. For all others attribute in the entry, a tag with that name and value is created.
        Specified by:
        writeEntry in interface ParserInterface
        Overrides:
        writeEntry in class XMLParser
        Parameters:
        entry - the entry containing the attributes to write.
        Throws:
        java.lang.Exception - if could not build the DOM tree or serialize the DOM element.
        See Also:
        DOMException
      • parseXML

        public org.w3c.dom.Node parseXML​(java.lang.String xml)
                                  throws java.lang.Exception
        Parses XML file to Document element.
        Parameters:
        xml - xml file to parse.
        Returns:
        parsed Document element.
        Throws:
        java.lang.Exception - If any I/O or parse errors occur; if xml is null
      • getXML

        public java.lang.String getXML​(Entry e)
                                throws java.lang.Exception
        Returns string representation of Entry object as a XML file.
        Parameters:
        e - the Entry object
        Returns:
        the buffer of the current writer object as a string.
        Throws:
        java.lang.Exception - if could not build the DOM tree or serialize the DOM element.