Service Message Writer

This is used to write requests for other services or to write a response for this service. It provides a simplified syntax for writing XML messages based on the Flat XML conventions.

ServiceMessageWriter = new com.metrici.xerula.ServiceMessageWriter(rootName) Create a new, empty, service message with the given root.

Use the application.newServiceRequest() and application.newServiceResponse() for creating service requests and responses.

put(path,value) Write a value to the message. Returns false if there is an error. There are versions which take strings or numbers.

The only possible error is that the path is not well formed. Scripts need not test for this if they are confident of the well-formedness of their paths.

String = getErrorMessage() Return the error message associated with the most recent put.
String = toString() Get a string view of the service message.

Flat XML

Flat XML is a convention for representing any XML document as a set of name=value pairs. It is used when invoking services.

The basic idea is that any simple XML document can be broken down so that each value is paired with the XPath representation of the containing element or attribute, relative to the root document.



Is the same as


The rules for this are:

  • The special name / identifies the root element. This implicitly precedes all other elements. This may contain more than one level, e.g. /=Wrapper/Service, but the first level must not contain any position specifiers.
  • Every element has a position. This defaults to 1, so the following are identical:
  • Repeating groups are identified by paths with position selectors. These must be numeric, greater than zero. They are output in numerical sequence, and any missing parts are added, e.g.


  • With the exception of the root element, no name may start or end with a slash.
  • Elements must contain either a value or other elements.
  • Attributes are not supported.
  • Namespaces, comments and processing instructions are not supported.
  • To code an empty element, code the element with empty data, e.g.
  • Duplicates are not permitted, and behaviour on passing duplicates is undefined.
  • name=value pairs are processed in sequence. However, in the case of nested groups, they can be processed out of sequence. (This allows the order of data to be garbled in an interim process, and to be recreated correctly at a later stage.)