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. When writing the XML document, the Parser uses attributes from the entry to build the document. The SOAP_CALL attribute is expected to contain the value for the SOAP call. Similarly, when reading, 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. When reading the document, each tag under the SOAP_CALL tag translates to an attribute in the entry object.
When working with the WebServices Connector, avoid starting attribute names with special characters (such as [0-9] [ - ' ( ) + , . / = ? ; ! * # @ $ % ]). Also, avoid having attribute names that include special characters (such as [ ' ( ) + , / = ?; ! * # @ $ % ] ). This is because WebServices builds on SOAP, which is XML. XML does not accept $ as in tags.
The following examples show an entry and a SOAP XML document as they are read or written.
*** Begin Entry Dump SOAP_CALL: 'updateLDAP' mail: ('john@doe.com)' uid: 'johnd' *** End Entry Dump
<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>
The Parser has the following parameters:
We can access the SOAP Parser from the script by dynamically loading the Parser and calling the methods to read or write SOAP documents. The following example 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 ("ibmdi.SOAP"); soap.initParser(); var soapxml = soap.getXML ( e ); task.logmsg ( "SOAP XML Document" ); task.logmsg ( soapxml ); // Write to a file var soap = system.getParser("ibmdi.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 );
Go to the root_directory/examples/soap directory of the IBM TDI installation.