SOAP Parser
Overview
The SOAP Parser reads/writes SOAP XML documents. The parser converts SOAP XML
documents to/from entry objects in a simple straightforward fashion. When
writing the XML document the parser will use attributes from the entry to build
the document. The SOAP_CALL attribute is expected to contain the value
for the SOAP call. Similarly, on read this attribute is set to reflect the first
tag following the SOAP-ENV:Body tag. Then for each attribute in the entry, a tag
with that name and value is created. Vice versa, when reading the document, all
tags under the soap-call tag translates to an attribute in the entry object.
The samples below show an entry and a SOAP XML document as they would be
read/written.
Sample Entry
*** Begin Entry Dump
SOAP_CALL: 'updateLDAP'
mail: 'john@doe.com'
uid: 'johnd'
*** End Entry Dump
Sample SOAP
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:updateLDAP xmlns:ns1="" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<uid xsi:type="xsd:string">johnd</uid>
<mail xsi:type="xsd:string">john@doe.com</mail>
</ns1:updateLDAP>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Configuration
The parser has the following parameters:
Parameter |
Description |
class |
com.architech.parser.rspSoapParser |
characterSet |
Optional
character set conversion. |
omitxmldeclaration |
Omit XML declaration header in output stream |
isvalidating |
Request a DTD/XSchema validating XML parser |
isnamespaceaware |
Request a namespace aware XML parser |
Parser Specific Calls
You can access the parser from your script by dynamically loading the
parser and calling the methods to read/write SOAP documents. The following
sample shows how to generate the XML document from an entry:
var e = system.newEntry();
e.setAttribute ("soap_call", "updateLDAP");
e.setAttribute ("uid", "johnd");
e.setAttribute ("mail", "john@doe.com");
// Retrieve the XML document as a string
var soap = system.getParser ("metamerge.SOAP");
soap.initParser();
var soapxml = soap.getXML ( e );
task.logmsg ( "SOAP XML Document" );
task.logmsg ( soapxml );
// Write to a file
var soap = system.getParser("metamerge.SOAP");
soap.setOutputStream ( new java.io.FileOutputStream("mysoap.xml") );
soap.writeEntry ( e );
soap.close();
// Read from file
soap.setInputStream ( new java.io.FileInputStream ("mysoap.xml") );
var entry = soap.readEntry();
// Read from string (from soapxml generated above)
var entry = soap.parseRequest( soapxml );
task.dumpEntry ( entry );
Downloads
Example using the SOAP parser
SOAP Parser, more general example. Links
HTTP EventHandler, SOAP and LDAP together. Check out the web-messaging.doc
file for more information
|