SOAP Server
Version 2.x
Develop
- Create a new project and name it soap_server_basic.
- Select the ScriptingServices sub-folder of the project and open the pop-up menu.
- Choose New -> Scripting Service.
- Choose Server-Side JavaScript Service from the list of available templates.
- Give it a meaningful name (e.g soap_server_basic.js).
- Replace the generated code in soap_server_basic.js with the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* globals $ */
/* eslint-env node, dirigible */
var soap = require("net/soap");
var request = require('net/http/request');
var response = require('net/http/response');
// Parse SOAP request
var message = soap.parseRequest();
// More fine grained
//var input = request.getInput();
//var mimeHeaders = soap.createMimeHeaders();
//var message = soap.parseMessage(mimeHeaders, input);
var requestPart = message.getPart();
var requestEnvelope = requestPart.getEnvelope();
var requestBody = requestEnvelope.getBody();
var childElements = requestBody.getChildElements();
printElements(childElements);
response.println(message.getText());
response.flush();
response.close();
function printElements(childElements) {
childElements.forEach(function(element) {
if (element.isSOAPElement()) {
var name = element.getElementName();
console.log(name.getLocalName() + ": " + element.getValue());
printElements(element.getChildElements());
}
});
}
Discover
To discover all available services, you can go to the Registry.
- From the main menu, choose Window -> Show Perspective -> Registry.
- The Registry perspective represents a view to the enabled runtime content. From its menu, choose Discover -> JavaScript to open the currently available server-side JavaScript service endpoints.
- You can see the list of available endpoints, where you can find yours by naming convention: {project}/{service path}