-
Notifications
You must be signed in to change notification settings - Fork 11
/
soap2json
executable file
·39 lines (30 loc) · 1.29 KB
/
soap2json
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
38
39
#!/usr/bin/node
// vim:ft=javascript
var soap = require("./index.js"),
express = require("express"),
server = express();
// if not root, use dummy config required by test script
// otherwise, parse config from command-line arguments
var config = (module.parent) ? { soapUrl: 'http://localhost:15099', port: 9876, prefix: 'api' }
: require('commander')
.option("-v, --verbose", "Enable extensive logs")
.option("-p, --port <port>", "Listening port")
.option("-u, --soap-url <url>", "SOAP server url")
.option("-P, --prefix <prefix>", "Url prefix. Defaults to none", "")
.parse(process.argv);
if (!config.port || !config.soapUrl) {
console.log("\n Missing one or more <required> options!");
console.log(config.helpInformation());
process.exit(1);
}
if (config.verbose)
server.use(express.logger({ format: '\x1b[1m:method\x1b[0m :url\x1b[0m :response-time ms\x1b[0m :status' }));
server.use( soap(config.soapUrl, config.prefix) );
if (config.verbose) {
console.log("Using SOAP server on: ", config.soapUrl);
console.log("Listening on port: ", config.port);
if (config.prefix !== "")
console.log("Service urls use prefix: ", config.prefix);
console.log();
}
server.listen(config.port);