the section called “Defining Input, Output.” shows you an example on how to use the types when defining the function.
XINS has some integrated types which facilitate the use of input and output parameters with the implementation.
Table 4. XINS integrated types
type | Java representation | Example |
_text | java.lang.String | hello world |
_boolean | boolean | true |
_int8 | byte | 25 |
_int16 | short | 2004 |
_int32 | int | 15 |
_int64 | long | 654654132135544566 |
_float32 | float | 25.6 |
_float64 | double | 3.14159 |
_date | org.xins.common.types.standard.Date.Value | 20040514 |
_timestamp | org.xins.common.types.standard.Timestamp.Value | 20040514115930 |
_property | Map<String, String> | upgrade%3Dtrue%26surname%3Dde%2BHaan |
_list | org.xins.common.types.standard.List.Value | item1%26item2%26item1 |
_set | org.xins.common.types.standard.Set.Value | item3%26item1%26item2 |
_base64 | byte[] | aGVsbG8= |
_hex | byte[] | 546573746f |
_url | String | http://www.google.com |
_descriptor | org.xins.common.service.Descriptor | descriptor=group, random, target1, target2 descriptor.target1=service, http://127.0.0.1:8080/my-project/, 8000 descriptor.target2=service, http://192.168.0.1:8080/my-project/, 8000 |
_xml | org.xins.common.xml.Element | <firstName>Alain</firstName> |
You can find an example using all these types in the function
demo\xins-project\apis\allinone\spec\SimpleTypes.fnc
.
As seen in the section called “Defining Input, Output.”, it's also possible to define your own type. Here is a list of the possible types to define in XINS:
: This
type accepts a PERL5 regular expression and allows you to define a
text that has some constraints in its format.<pattern>
<enum>
: This type must contain a list
of <item>
elements, each item element must
have a value
attribute that contains the value of
the item and can have a name
attribute that
contains the description of the item. If the name is not defined
it's set by default to the value of the item.
<int8>
,
<int16>
, <int32>
,
<int64>
: These types define a number. They
accept the optional attributes min
and
max
that can be used to set a minimum and a
maximum value for the parameter.
<float32>
,
<float64>
: These types define a floating
point number. They accept the optional attributes
min
and max
that can be used
to set a minimum and a maximum value for the parameter.
<properties>
: This type is similar to
the _property
type but it allows you to specify a
type for the keys and the values of the property by using the
optional attributes nameType
and
valueType
. If not specified the type
_text
will be used.
<list>
and
<set>
: These types are used to define a
list of values in a parameter. The type of the value can be
restricted by using the optional attribute type
.
If not specified the default value for the type
attribute is _text
.
<xml>: This type is used to specify an XML paramter. It
accept the attribute xsdLocation
that can be
a URL or a local file in the spec
directory.
<base64>
,
<hex>
: This type defines a binary. They
accept the optional attributes min
and
max
that can be used to set a minimum and a
maximum size in bytes for the binary.
You can find an example using some of these types in the function
demo\xins-project\apis\allinone\spec\DefinedTypes.fnc
.
If you have more than one API, you may want to reuse types defined
in other APIs (for example EMail.typ, Account.typ, LastName.typ, ...).
Instead of copying the file to the new API, you can also point to this
type. This is done by using <api name>/<type
name>
in api.xml and in the function(s)
specification.
For example:
<type name="petstore/EMail"/>
<param name="outputEMail" required="false" type="petstore/EMail"> <description>An example of output shared type.</description> </param>