2018 SOAP(2)SAOP with TS module soap-decorators

TypeScript SOAP and example
https://github.com/RobinBuschmann/soap-typescript
https://github.com/RobinBuschmann/soap-typescript/tree/master/example
Prepare the ENV
Search “experimentalDecorators” in VSCode and set that to true.

Set Up a Simple Project named services.soapexport, the sample package.json file will be as follow:
{
"author": "Data Team",
"dependencies": {
"@types/autobahn": "^0.9.37",
"@types/chai": "^4.0.4",
"@types/mocha": "^2.2.43",
"@types/node": "^8.0.28",
"@types/sinon": "^2.3.5",
"@types/lodash": "4.14.106",
"autobahn": "^0.12.0",
"aws-sdk": "^2.103.0",
"base-64": "^0.1.0",
"chai": "^4.1.2",
"config": "^1.26.2",
"dynamodb-local": "0.0.18",
"log4js": "^2.3.3",
"redis": "^2.8.0",
"soap-decorators": "^1.0.2",
"request": "^2.73.0",
"request-promise": "^4.1.1",
"sinon": "^3.2.1",
"sinon-test": "^2.1.1",
"typescript": "^2.1.4",
"uuid-validate": "0.0.2",
"express": "^3.20.0",
"express-soap": "1.0.3",
"soap": "0.23.0",
"reflect-metadata": "^0.1.8"
},
"description": "Lifeszie cloud directory microservice",
"devDependencies": {
"del": "^3.0.0",
"gulp": "^3.9.1",
"gulp-env": "^0.4.0",
"gulp-mocha": "^2.2.0",
"gulp-shell": "^0.5.2",
"gulp-tslint": "^4.3.4",
"gulp-typescript": "^3.1.3",
"mocha": "^3.5.3",
"mocha-sinon": "^2.0.0",
"tslint": "^3.13.0"
},
"engines": {
"node": ">=4.1.1"
},
"keywords": [
"typescript",
"soap",
"nodejs"
],
"license": "(c) Sillycat 2016",
"name": "user-microservice",
"scripts": {
"build": "gulp build",
"dev": "NODE_ENV=dev node build/src/server.js",
"beta": "NODE_ENV=stage node build/src/server.js",
"start": "node build/src/server.js",
"test": "gulp test",
"tsc": "tsc",
"client": "node build/test/client.js",
"loglevel": "node build/src/logger.js"
},
"version": "0.0.1"
}

The tsconfig.json and tslint.json will be as follow:
{
"compilerOptions": {
"outDir": "build",
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"exclude": [
"node_modules",
"typings"
]
}

{
"rules": {
"class-name": true,
"curly": true,
"eofline": false,
"forin": false,
"indent": [
true,
4
],
"label-position": true,
"label-undefined": true,
"max-line-length": [
true,
140
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-string-literal": false,
"no-trailing-whitespace": true,
"no-unused-variable": false,
"no-unreachable": true,
"no-use-before-declare": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"radix": true,
"semicolon": true,
"triple-equals": [
true,
"allow-null-check"
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator"
]
}
}

Define the Input and Output, CalculatorInput.ts and CalculatorOutput.ts
import {XSDComplexType, XSDElement} from 'soap-decorators';

@XSDComplexType
export class CalculatorInput {

@XSDElement
a: number;

@XSDElement
b: number;

}

import {XSDComplexType, XSDElement} from 'soap-decorators';

@XSDComplexType
export class CalculatorResult {

@XSDElement
value: number;
}

Define the simple Service on top of annotation in CalculatorService.ts
import {SoapService, SoapOperation} from 'soap-decorators';
import {CalculatorInput} from './CalculatorInput';
import {CalculatorResult} from './CalculatorOutput';

@SoapService({
portName: 'CalculatorPort',
serviceName: 'CalculatorService'
})
export class CalculatorService {
@SoapOperation(CalculatorResult)
add(data: CalculatorInput, res: (res: CalculatorResult) => any): void {
res({
value: data.a + data.b
});
}

@SoapOperation(CalculatorResult)
subtract(data: CalculatorInput, res: (res: CalculatorResult) => any): void {
res({
value: data.a - data.b
});
}
}

Start the Service in soap.ts
import * as express from 'express';
import * as http from 'http';
import {CalculatorService} from './CalculatorService';
import {soap} from 'soap-decorators';

export class SoapServer {

private server;

constructor(listenPort: number, address: string) {
}

public async init() {

}

public async start() {
let app = express();
let calculatorService = new CalculatorService();
app.use('/calculatorService', soap(calculatorService));
http.createServer(app)
.listen(3000, () => console.log('SOAP Server listining') );

// let app = express();
// let calculatorService = new CalculatorService();
// let xml = require('fs').readFileSync('/Users/hluo/company/code/services.soapexport/wsdl/calculatorService.wsdl', 'utf8');
// app.listen(3000, function(){
// soap.listen(app, '/calculatorService', calculatorService, xml);
// });
}

}

Directly Use SOAP Package
https://github.com/vpulim/node-soap#basicauthsecurity
https://stackoverflow.com/questions/22884513/simple-webservice-with-node-soap

References:
https://www.npmjs.com/package/soap
https://github.com/benerone/soapStub

https://github.com/vpulim/node-soap
https://github.com/RobinBuschmann/soap-typescript

More example
https://blog.csdn.net/cwallow/article/details/41983467
https://github.com/tan-tan-kanarek/node-soap-server
https://stackoverflow.com/questions/22884513/simple-webservice-with-node-soap
https://stackoverflow.com/questions/20740975/how-to-get-started-node-soap
https://github.com/tan-tan-kanarek/node-soap-server

Directly use the API
https://github.com/vpulim/node-soap#basicauthsecurity
https://stackoverflow.com/questions/22884513/simple-webservice-with-node-soap

2018 SOAP(2)SAOP with TS module soap-decorators相关推荐

  1. 2018 BMCV 《BAM: Bottleneck Attention Module》Pytorch实现

    import torch from torch import nn from torch.nn import init# 通道注意力+空间注意力的改进版 # 方法出处 2018 BMCV <BA ...

  2. java中soap是什么,java中的soap的通讯

    由于 gSOAP 具有相当不错的兼容性, 通过 gSOAP, 我们就可以调用由 Java, .Net, Delhpi, PHP 等语言开发的 SOAP 服务,或者向它们提供 SOAP 服务. gSOA ...

  3. java写soap客户端_Java:简单的SOAP客户端

    我正在寻找一个用于 Java的SOAP客户端. Apache Axis对我来说看起来很blo肿.我不明白为什么Java必须如此复杂.例如,在PHP中,我所要做的就是: $global_service_ ...

  4. python发送soap报文_python用http发送soap报文进行webservice接口调用

    最近学习了python用http发送soap报文进行webservice接口调用,从网上找了些资料,为了方便下次温习,在此留下代码片段,也望高手指点: #!/usr/bin/env python # ...

  5. php soap 加符号报错,php soap错误获取http标头

    我正在开发一个 PHP脚本,它通过SOAP连接处理大量数据.如果脚本没有遇到任何错误,则估计脚本的总运行时间为几天.我遇到的问题是脚本将运行一段时间,从一小时到一天,然后SOAP连接将死于错误&quo ...

  6. java soap 解析_用Java解析SOAP响应

    我无法使用Java(使用Bonita Open Solution BPM)解析SOAP响应. 我有以下SOAP响应(在IBM Content Manager中搜索文档: SOAP响应返回1个匹配的文档 ...

  7. android soap webservice 数据流传输,Android利用Soap读取WebService并且解析XML的DataSet数据...

    一.Soap的结构 调用webService需要以下几个参数:命名空间.Soap Action.WSDL的URL.方法名.接下来以调用火车列车信息数据为例,webService地址为:webservi ...

  8. Linux编译安装 php soap模块

    环境 CentOS6.3 PHP5.4.22 1. 下载对应版本的php源码包,解压 例如  /tmp/php-5.4.22 2. 在解压后的目录执行 ./configure --enable-soa ...

  9. Android与服务器端数据交互(基于SOAP协议整合android+webservice)

    转自:http://www.cnblogs.com/zhangdongzi/archive/2011/04/19/2020688.html 上一节中我们通过http协议,采用HttpClient向服务 ...

最新文章

  1. c语言字符串机考题,2016全国计算机二级《C语言》机考试题及答案
  2. Transformer大升级!谷歌、OpenAI联合推出分层模型,刷榜ImageNet32刷新SOTA
  3. Ubuntu: 为firefox安装flash插件
  4. 基于便签纸的无限延生学习方法
  5. 迷宫收集星星 并查集解答
  6. 互联网广告系统综述四定向
  7. BAT面试进阶:最全Memcached面试30题含答案
  8. python的编程模式有哪两种_python程序的两种运行方式是什么
  9. python接口自动化参数化_python接口自动化6-参数化关联
  10. PAT 1011 A+B 和 C(C语言)
  11. 【火灾检测】基于matlab GUI火灾检测【含Matlab源码 249期】
  12. 如何在linux系统上安装wine来运行.exe文件
  13. Drool学习记录(二) Kie Session、Truth maintenance
  14. 如何将文件或文件夹加入杀毒软件白名单步骤
  15. 约瑟夫生死者游戏_独立游戏从死者特许经营中夺冠时,游戏玩家获胜
  16. linux学校_济南教师招聘 |济南市益友培训学校7大岗位教师招聘(月薪4k15k、包住)...
  17. 了解如何在Windows中安全删除文件
  18. html+js 调用摄像头识别二维码
  19. 开源:MIS金质打印通原理及实现 Step by step (1)
  20. 不同范数下的余弦定理_什么是绝对矩阵范数?

热门文章

  1. 国产什么品牌的蓝牙耳机比较好?半入耳式蓝牙耳机排行榜
  2. nginx处理post请求之数据转发
  3. 毕业生必知二三事。给即将毕业的师弟师妹看看,很有用的~~~~
  4. 电商订单提交后的基本处理
  5. 【树图科技头条】2022年11月30日 星期三 国家体育总局主办的CFC(全国全民体能大赛)发行基于Conflux的数藏
  6. TM4C123G学习记录(5)--PWM输出
  7. PDF 文字提取软件
  8. 小步创想 产品经理 春招面经
  9. kingston DataTraveler2.0 4GU盘量产成功
  10. 《红楼梦》中的宗教信仰