Implement SOAP methods implementing-soap-methods
Introduction introduction
It is possible to create SOAP methods in JavaScript. This function simply enables applicative processes, it can avoid developing JSPs and their calling in the forms.
These SOAP methods behave in the same way as those defined natively in the application. The same attributes are supported: static, key only and const.
Define a method library defining-a-method-library
Creating a method library involves two stages:
- The SOAP method declaration,
- Definition (or implementation) in JavaScript.
Declaration declaration
Start by declaring the methods in the schemas (for more on how to create and edit schemas, refer to this section).
Their declaration is similar to that of native methods, except that you need to add the 鈥榣ibrary鈥 attribute specifying the name of the method library where the definition is located.
This name coincides with the name (with the namespace) of the 鈥楯avaScript Code鈥 type entity.
Example:
The testLog(msg) method is declared in an nms:recipient extension
<method name="testLog" static="true" library="cus:test">
<parameters>
<param name="message" type="string" inout="in"/>
</parameters>
</method>
Definition definition
SOAP methods are implemented in the form of JavaScript function grouped in a script representing a library.
The script can contain code to be executed during initial library loading.
1. Name
The name of the function must comply with the following format:
<schema-namespace>_<schema-name>_<method-name>
Example:
The following JavaScript function is the implementation of the method described above. It shall be defined in the 鈥楯avaScript Code鈥 type entity using the 鈥榗us:test鈥 name.
function nms_recipient_testLog(message)
{
logInfo("*** " + message)
}
2. Signature
The function鈥檚 signature must include an argument for each 鈥榠n鈥 or 鈥榠nout鈥 parameter of the declaration.
Specific cases:
- non-static methods: the function must include an additional argument first, coinciding with the XML entity passed in the form of an 鈥榵ml鈥 (E4X) type object.
- 鈥渒ey only鈥 type methods: the function must include an additional argument first, coinciding with the key passed in the form of character strings.
3. Returned values
The function must return a value for each 鈥榦ut鈥 or 鈥榠nout鈥 type parameter. Specific case: If the method is declared without any of the 鈥榮tatic鈥, 鈥榢ey only鈥 or 鈥榗onst鈥 attributes, the first returned value must coincide with the modified entity. It is possible to return a new object or to return the first modified parameter.
For example:
function nms_recipient_setLastName(self, name)
{
self.@lastName = name
return self
}
When several values are to be returned, they must be displayed in a table.
Example:
function nms_recipient_getKey(self)
{
return [self.@firstName, self.@lastName]
}