Table of Contents
SMODL or Simple MethOd Definition Language is an XML-dialect to define a service as a collection of methods. A method is defined by a set of method arguments and a method return value. The possible type values for method arguments and the method result can be either a built-in type, a user-defined structured type or an array type.
Example 1. Calculator service
<?xml version="1.0" encoding="UTF-8"?>
<service name="SimpleCalculator" targetNamespace="http://localhost/calculator"
xmlns="http://smodl.org/v1">
<doc>Simple calculator service to perform basic arithmetic operations.</doc>
<method name="Add">
<doc>Calculate the sum of 2 items.</doc>
<arg name="item1" type="float"/>
<arg name="item2" type="float"/>
<result type="float"/>
</method>
<method name="Negate">
<doc>Negate the value.</doc>
<arg name="value" type="float"/>
<result type="float"/>
</method>
<method name="Multiply">
<doc>Calculate sum of 2 factors.</doc>
<arg name="factor1" type="float"/>
<arg name="factor2" type="float"/>
<result type="float"/>
</method>
<method name="Inverse">
<doc>Calculate the inversion of the value.</doc>
<arg name="value" type="float"/>
<result type="float"/>
</method>
</service>
The set of possible data types used in SMODL is divided into 3 categories: built-in types, user-defined structs and arrays.
Built-in types are listed in the following table in a comparison with corresponding types from the XML Schema.
Table 1. SMODL built-in type
| Type name | Description | XML Schema type |
|---|---|---|
binary | arbitrary binary data | xsd:base64Binary |
bool | boolean type that has two values, true and
false | xsd:base64Binary |
dateTime | a particular moment in time | xsd:dateTime |
double | IEEE double-precision 64-bit floating point type | xsd:double |
float | IEEE single-precision 32-bit floating point type | xsd:float |
int | 32-bit integer type | xsd:int |
long | 64-bit integer type | xsd:long |
string | arbitrary character string | xsd:string |
A user-defined structured type or struct represents in SMODL a collection of named fields where each field represents a value of a particular type.
All SMODL XML elements belong to http://smodl.org/v1 namespace. The root element of the SMODL service specification is the service element.
In the following description of SMODL XML elements all attributes are required unless explicitly specified as optional.
Specifies the name and the type of an argument of a SMODL method.
nameName of the argument. For a particular method, all arguments names must be unique and must satisfy restrictions on name attribute.
typeType of the argument. See type attribute.
All arguments of a SMODL method are required. If you need to declare a method that accepts optional data, then use a struct with nullable fields for that.
Specifies the semantic or provides other documentation of a particular SMODL element.
Specifies the name and the type of a field in a struct instance.
nameName of the field. For a particular struct, all fields names must be unique and and must satisfy restrictions on name attribute.
typeType of the field. See type attribute.
nullableSee nullable attribute.
See constraints and maxExclusive constraint.
See constraints and maxInclusive constraint.
See constraints and maxLength constraint.
Specifies a method of a SMODL service as a sequence of method arguments and a method result. Each service must define at least one method.
nameName of the method. For a particular service, all methods names must be unique and must satisfy restrictions on name attribute.
See constraints and minExclusive constraint.
See constraints and minInclusive constraint.
See constraints and minLength constraint.
See constraints and pattern constraint.
Specifies the result of a method call in a SMODL service.
typeType of a method return value. See type attribute.
nullableSee nullable attribute.
The root element of SMODL that specifies a service as a collection of methods, struct types and type.
nameName of the service. This attribute value must satisfy restrictions on name attribute.
targetNamespaceTarget namespace of the service. Must be a URI.
Specifies a struct of a SMODL service, a complex type representing collection of typed fields.
nameName of the struct. For a particular service, all structs names must be unique and must satisfy restrictions on name attribute.
baseOptional name of a base struct that this struct extends. The base struct can be defined either before or after this struct.
Specifies an alias name for a particular type together with its constraints.
nameName of the new type alias. It must satisfy restrictions on name attribute.
typeType that this typedef aliases. See type attribute.
nullableSee nullable attribute.
arg, result, field and typedef in SMODL represent elements that define typed values. That is, all elements values should have a specific type. For all these elements some additional constraints can be introduced in order to limit corresponding elements values. This to be specified using child elements according to the following table.
The following elements define constraints on a particular type value and have common structure:
These elements have the same semantics as the corresponding XML Schema constraint facets as defined in the XML Schema Part 2: Section 4.3.
The value of the constraint. See corresponding section of XML Schema Specification for details.
The semantics of the constraint element
Table 3. Supported type constraints
| Constraint element | Meaning of the value attribute |
|---|---|
maxExclusive | The exclusive upper bound of the value space for a numeric type. |
maxInclusive | The inclusive upper bound of the value space for a numeric type. |
maxLength | The maximum number of characters in a string value. |
minExclusive | The exclusive lower bound of the value space for a numeric type. |
minInclusive | The inclusive lower bound of the value space for a numeric type. |
minLength | The minimum number of characters in a string value. |
pattern | The XML Schema regular expression as defined by Appendix F of The XML Schema specification, part 2 to constrain the string values only to strings that matches the expression. |
SMODL elements arg, method, struct and typedef
have required name attribute that assigns a name to
a corresponding definition. In all cases, the value of the attribute is restricted to
the following pattern:
[A-Za-z][A-Za-z0-9_]
That is, each name must begin with an ASCII letter and can follow
by zero or more ASCII letters, digits or _
symbols. This ASCII-only restriction ensures compatibility with the
widest possible selection of protocols and programming languages.
SMODL elements arg, field, result and typedef have
required type attribute that specifies a type of
a corresponding definition. In all such cases, the value of the
attribute must be either one of built-in types or a name of
a struct defined by a service followed by zero or more of
[] pairs. Presence of []
indicates that the type is an array type and number of
[]
gives dimensions of the array type.
Below listed excerpts from a smodl file that demonstrate use of constrained types: int, float, double, long and string.
Example 2. Int type constraints
<method name="getInint"> <arg name="i" type="int"/> <result type="inint"/> </method> <method name="getExint"> <arg name="i" type="int"/> <result type="exint"/> </method> <method name="getInintArray"> <arg name="i" type="int[]"/> <result type="inint[]"/> </method> <method name="getExintArray"> <arg name="i" type="int[]"/> <result type="exint[]"/> </method> <typedef name="inint" type="int"> <maxInclusive value="2"/> <minInclusive value="-1"/> </typedef> <typedef name="exint" type="int"> <maxExclusive value="2"/> <minExclusive value="-1"/> </typedef>
Example 3. Float type constraints
<method name="getInfloat"> <arg name="i" type="float"/> <result type="infloat"/> </method> <method name="getInfloatArray"> <arg name="i" type="float[]"/> <result type="infloat[]"/> </method> <method name="getExfloat"> <arg name="i" type="float"/> <result type="exfloat"/> </method> <method name="getExfloatArray"> <arg name="i" type="float[]"/> <result type="exfloat[]"/> </method> <typedef name="infloat" type="float"> <minInclusive value="-1.e-10"/> <maxInclusive value="0.001"/> </typedef> <typedef name="exfloat" type="float"> <minExclusive value="-1.e-10"/> <maxExclusive value="0.001"/> </typedef>
Example 4. Double type constraints
<method name="getIndouble"> <arg name="i" type="double"/> <result type="indouble"/> </method> <method name="getIndoubleArray"> <arg name="i" type="double[]"/> <result type="indouble[]"/> </method> <method name="getExdouble"> <arg name="i" type="double"/> <result type="exdouble"/> </method> <method name="getExdoubleArray"> <arg name="i" type="double[]"/> <result type="exdouble[]"/> </method> <typedef name="indouble" type="double"> <minInclusive value="-1.e-10"/> <maxInclusive value="0.001"/> </typedef> <typedef name="exdouble" type="double"> <minExclusive value="-1.e-10"/> <maxExclusive value="0.001"/> </typedef>
Example 5. Long type constraints
<method name="getInlong"> <arg name="i" type="long"/> <result type="inlong"/> </method> <method name="getInlongArray"> <arg name="i" type="long[]"/> <result type="inlong[]"/> </method> <method name="getExlong"> <arg name="i" type="long"/> <result type="exlong"/> </method> <method name="getExlongArray"> <arg name="i" type="long[]"/> <result type="exlong[]"/> </method> <typedef name="inlong" type="long"> <maxInclusive value="20000000000"/> <minInclusive value="-3000000000000"/> </typedef> <typedef name="exlong" type="long"> <maxExclusive value="20000000000"/> <minExclusive value="-3000000000000"/> </typedef>
Example 6. String type constraints
<method name="getString">
<arg name="p" type="string"/>
<result type="mystring"/>
</method>
<method name="getStringArray">
<arg name="p" type="string[]"/>
<result type="mystring[]"/>
</method>
<method name="getStringStruct">
<arg name="p" type="strstruct"/>
<result type="strstruct"/>
</method>
<struct name="strstruct">
<field name="str" type="mystring"/>
</struct>
<typedef name="mystring" type="string">
<maxLength value="16"/>
<minLength value="4"/>
<pattern value="[a-z]*"/>
</typedef>"