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 voiddumpNodes(java.lang.String prefix, org.w3c.dom.NodeList list)Prints the contents of theNodeListdepending on the types of the .org.w3c.dom.NodefindBodyElement()Finds the SOAP Body element.org.w3c.dom.NodefindNamedElement(org.w3c.dom.NodeList list, java.lang.String name)Finds node element by given name.org.w3c.dom.NodegetElement(org.w3c.dom.Node parent, int index)ReturnsNodeobject by given index.java.util.Vector<org.w3c.dom.Element>getElementList(org.w3c.dom.Node parent)Return list containing all children of theparentnode.org.w3c.dom.NodegetFirstText(org.w3c.dom.Node parent)Gets the text of the first child of a givenNode.java.lang.StringgetVersion()Version information.java.lang.StringgetXML(Entry e)Returns string representation ofEntryobject as a XML file.voidinitOutput()Initializes the output Documentvoidp(java.lang.String s)Writes a message to the log.EntryparseRequest(java.lang.Object request)Sets the current input stream and initializes the parser.org.w3c.dom.NodeparseXML(java.lang.String xml)Parses XML file toDocumentelement.voidprintNode(java.lang.String prefix, org.w3c.dom.Node n)Prints the contents of theNodedepending on its type.EntryreadEntry()Reads SOAP XML documents.voidwriteEntry(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.ExceptionInitializes the output Document- Overrides:
initOutputin 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-NodeListto search into.name- the name of the searched node.- Returns:
- first
Elementnode namedname.
-
getElementList
public java.util.Vector<org.w3c.dom.Element> getElementList(org.w3c.dom.Node parent)
Return list containing all children of theparentnode.- Parameters:
parent- the parentNode.- Returns:
Vectorwith allElementchildren
-
getElement
public org.w3c.dom.Node getElement(org.w3c.dom.Node parent, int index)ReturnsNodeobject by given index.- Parameters:
parent- the parentNode.index- the index of the desiredNode.- Returns:
Nodeobject atindexposition.
-
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 theNodeListdepending on the types of the .- Parameters:
prefix- prefix of the log message.list- theNodeListobject 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 theNodedepending on its type.- Parameters:
prefix- prefix of the log message.n- theNodeto 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_CALLis set to reflect the first tag following theSOAP-ENV:Bodytag. Each tag under the SOAP_CALL tag translates to an attribute in the entry object.- Specified by:
readEntryin interfaceParserInterface- Overrides:
readEntryin 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 theentryto build the document. TheSOAP_CALLattribute 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:
writeEntryin interfaceParserInterface- Overrides:
writeEntryin 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.ExceptionParses XML file toDocumentelement.- Parameters:
xml- xml file to parse.- Returns:
- parsed
Documentelement. - Throws:
java.lang.Exception- If any I/O or parse errors occur; ifxmlisnull
-
getXML
public java.lang.String getXML(Entry e) throws java.lang.Exception
Returns string representation ofEntryobject as a XML file.- Parameters:
e- theEntryobject- 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:
getVersionin interfaceVersionInfoInterface- Overrides:
getVersionin classXMLParser- Returns:
- version information
-
-