Package com.ibm.di.parser
Class SOAPParser
- java.lang.Object
-
- com.ibm.di.parser.ParserImpl
-
- com.ibm.di.parser.XMLParser
-
- com.ibm.di.parser.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.
-
-
Field Summary
-
Fields inherited from class com.ibm.di.parser.XMLParser
children, curindex, db, entrytag, inputDoc, outputDoc, toplevel, toplevelInput, useCData, valuetag
-
Fields inherited from class com.ibm.di.parser.ParserImpl
_debug, myConfiguration
-
-
Constructor Summary
Constructors Constructor Description SOAPParser()
Creates SOAPParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dumpNodes(java.lang.String prefix, org.w3c.dom.NodeList list)
Prints the contents of theNodeList
depending on the types of the .org.w3c.dom.Node
findBodyElement()
Finds the SOAP Body element.org.w3c.dom.Node
findNamedElement(org.w3c.dom.NodeList list, java.lang.String name)
Finds node element by given name.org.w3c.dom.Node
getElement(org.w3c.dom.Node parent, int index)
ReturnsNode
object by given index.java.util.Vector<org.w3c.dom.Element>
getElementList(org.w3c.dom.Node parent)
Return list containing all children of theparent
node.org.w3c.dom.Node
getFirstText(org.w3c.dom.Node parent)
Gets the text of the first child of a givenNode
.java.lang.String
getVersion()
Version information.java.lang.String
getXML(Entry e)
Returns string representation ofEntry
object as a XML file.void
initOutput()
Initializes the output Documentvoid
p(java.lang.String s)
Writes a message to the log.Entry
parseRequest(java.lang.Object request)
Sets the current input stream and initializes the parser.org.w3c.dom.Node
parseXML(java.lang.String xml)
Parses XML file toDocument
element.void
printNode(java.lang.String prefix, org.w3c.dom.Node n)
Prints the contents of theNode
depending on its type.Entry
readEntry()
Reads SOAP XML documents.void
writeEntry(Entry entry)
Writes SOAP XML document.-
Methods inherited from class com.ibm.di.parser.XMLParser
closeParser, error, fatalError, flush, getOmitXMLDeclaration, initInput, initParser, registerScriptBeans, setOmitXMLDeclaration, warning
-
Methods inherited from class com.ibm.di.parser.ParserImpl
debug, debugMode, getClassInstance, getContext, getDebug, getInputStream, getOutputStream, getParam, getParser, getReader, getWriter, isDeltaSupported, logmsg, querySchema, setConfiguration, setContext, setDebug, setInputStream, setInputStream, setInputStream, setOutputStream, setOutputStream, setParam, setParser
-
-
-
-
Method Detail
-
initOutput
public void initOutput() throws java.lang.Exception
Initializes the output Document- Overrides:
initOutput
in classXMLParser
- 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 requestedReader
.- 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 namedname
.
-
getElementList
public java.util.Vector<org.w3c.dom.Element> getElementList(org.w3c.dom.Node parent)
Return list containing all children of theparent
node.- Parameters:
parent
- the parentNode
.- Returns:
Vector
with allElement
children
-
getElement
public org.w3c.dom.Node getElement(org.w3c.dom.Node parent, int index)
ReturnsNode
object by given index.- Parameters:
parent
- the parentNode
.index
- the index of the desiredNode
.- Returns:
Node
object atindex
position.
-
getFirstText
public org.w3c.dom.Node getFirstText(org.w3c.dom.Node parent)
Gets the text of the first child of a givenNode
.- Parameters:
parent
- the parentNode
- Returns:
- string containing the text value.
-
dumpNodes
public void dumpNodes(java.lang.String prefix, org.w3c.dom.NodeList list)
Prints the contents of theNodeList
depending on the types of the .- Parameters:
prefix
- prefix of the log message.list
- theNodeList
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 theNode
depending on its type.- Parameters:
prefix
- prefix of the log message.n
- theNode
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 attributeSOAP_CALL
is set to reflect the first tag following theSOAP-ENV:Body
tag. Each tag under the SOAP_CALL tag translates to an attribute in the entry object.- Specified by:
readEntry
in interfaceParserInterface
- Overrides:
readEntry
in classXMLParser
- 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 theentry
to build the document. TheSOAP_CALL
attribute is expected to contain the value for the SOAP call. For all others attribute in theentry
, a tag with that name and value is created.- Specified by:
writeEntry
in interfaceParserInterface
- Overrides:
writeEntry
in classXMLParser
- 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 toDocument
element.- Parameters:
xml
- xml file to parse.- Returns:
- parsed
Document
element. - Throws:
java.lang.Exception
- If any I/O or parse errors occur; ifxml
isnull
-
getXML
public java.lang.String getXML(Entry e) throws java.lang.Exception
Returns string representation ofEntry
object as a XML file.- Parameters:
e
- theEntry
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.
-
getVersion
public java.lang.String getVersion()
Version information.- Specified by:
getVersion
in interfaceVersionInfoInterface
- Overrides:
getVersion
in classXMLParser
- Returns:
- version information
-
-