要想在NodeJS中调用SS生成的DLL, 需要借助EdgeJS.

EdgeJS: http://tjanczuk.github.io/edge/

如果你还不知道如何在SS中生成DLL, 请查看: Spider Studio 新版本 (x-mas) - 可以引入第三方程序集, 可以将脚本生成为DLL

下面以曾经写过的XML/JSON互转的脚本为例 (C#中另辟蹊径解决JSON / XML互转的问题) 说明如何在NodeJS中应用SS DLL:

1. 安装edgejs

npm install edge

2. 为www.utilities_online.info.XmlJsonConverter.dll编写一个javascript的代理脚本

一共两个方法, Xml2Json & Json2Xml:

var edge = require('edge');

exports.xml2json = edge.func({
source: function() {/* using System.Threading;
using System.Threading.Tasks;
using www.utilities_online.info; public class Startup
{
public async Task<object> Invoke(object input)
{
object result = null;
Thread t = new Thread(new ParameterizedThreadStart((p) => {
using(var proxy = new XmlJsonConverter())
{
proxy.Init();
result = proxy.Xml2Json(p.ToString());
}
} ));
t.SetApartmentState(ApartmentState.STA);
t.IsBackground = true;
t.Start(input);
while (t.ThreadState != ThreadState.Stopped)
{
Thread.Sleep(100);
}
return result;
}
}
*/},
references: [ __dirname + '\\www.utilities_online.info.XmlJsonConverter.dll' ]
}); exports.json2xml = edge.func({
source: function() {/* using System.Threading;
using System.Threading.Tasks;
using www.utilities_online.info; public class Startup
{
public async Task<object> Invoke(object input)
{
object result = null;
Thread t = new Thread(new ParameterizedThreadStart((p) => {
using(var proxy = new XmlJsonConverter())
{
proxy.Init();
result = proxy.Json2Xml(p.ToString());
}
} ));
t.SetApartmentState(ApartmentState.STA);
t.IsBackground = true;
t.Start(input);
while (t.ThreadState != ThreadState.Stopped)
{
Thread.Sleep(100);
}
return result;
}
}
*/},
references: [ __dirname + '\\www.utilities_online.info.XmlJsonConverter.dll' ]
});

3. 编写服务脚本 www.utilities_online.info.XmlJsonConverter.js

var http = require('http');
var xmlJson = require('./www.utilities_online.info.XmlJsonConverter.proxy.js'); var person = { person:{ name:'Mike', age: }}; var proxy = http.createServer(function (req, res) {
res.writeHead(, {'Content-Type': 'application/xml'});
var xml = xmlJson.json2xml(JSON.stringify(person), true);
console.log(xml);
res.end(xml);
}).listen();

4. 运行, 查看效果:

最新文章

  1. 【Win 10 应用开发】Sqlite 数据库的简单用法
  2. C Primer Plus_第8章_字符输入输出和输入确认_编程练习
  3. Linux 下从头再走 GTK+-3.0 (五)
  4. Elasticsearch-2.3.x填坑之路
  5. 解决My eclipse 工程发布时端口占用问题
  6. thrift
  7. ZOJ 1099 HTML
  8. OS X Git连接github
  9. [!] CocoaPods was not able to update the `master` repo...
  10. Delphi TdxBarManager通过代码生成菜单
  11. delphi 集合的用法
  12. SLAM入门之视觉里程计(5):单应矩阵
  13. [Swift]LeetCode413. 等差数列划分 | Arithmetic Slices
  14. IDEA打包jar包
  15. es安装elasticsearch-sql插件
  16. DefWindowProc是一个会产生消息的函数
  17. mysql 多列索引的生效规则,生成1000w数据的存储过程
  18. 34.js----JS 开发者必须知道的十个 ES6 新特性
  19. [bug]不包含“AsNoTracking”的定义
  20. 截图保存 matlab

热门文章

  1. NGUI系列教程七(序列帧动画)
  2. Install certificates needed for Visual Studio offline installation
  3. div+css 和 xhtml+css是一回事么?
  4. 分享六个基于Bootstrap的实用开发教程和模板演示
  5. mysql查找数据库中是否已经存在某张表
  6. http协议中content-length 以及chunked编码分析
  7. [Oracle] SQL*Loader 详细使用教程(5)- 典型例子
  8. IIS7 大文件上传 asp.net iis配置
  9. Effective java读书札记第一条之 考虑用静态工厂方法取代构造器
  10. 隐函数画图with R