Web Services 实作OCPP方法

3z6pesqy  于 2022-11-15  发布在  其他
关注(0)|答案(1)|浏览(187)

我在同一个.js文件上创建了SOAP客户端和服务器。

索引.js

"use strict"
var soap = require('strong-soap').soap;
var express = require('express');
var Promise = require('promise');
var app = express();
var WSDL = soap.WSDL;

var xml = require('fs').readFileSync('centralsystemservice_1.5.wsdl','utf8');
var xmlCl = require('fs').readFileSync('chargingpointservice_1.5.wsdl','utf8');
var url = './chargingpointservice_1.5.wsdl';
function aa(args)
{
    console.log("<<<>>>",args.bb);
}

var path = "/dek";
var port = 9330;




soap.createClient(url, {}, (err, client) => {
  if(err)
    throw err;
  else 
  {
    client.setEndpoint('http://localhost:9330/Ocpp/ChargePointService/');
    client.ChargePointService.ChargePointServiceSoap12.Reset();
  }
});

app.post('/Ocpp/ChargePointService/', (req, res, next) => {
    console.log(req);
})


app.listen(port, () => {
  console.log("Listening on port "+port);
  soap.listen(app, path, service, xml);
});

我不能写的内容.wsdl文件,因为太长。我有一个问题:如何实现心跳或引导通知等功能?在编写OCPP协议中通信的功能时有什么限制吗?

vsaztqbk

vsaztqbk1#

我建议你用json代替soap,用json容易多了。
例如,在BootNotification的情况下,工作站启动并发送到您的Ocpp服务器:

[2,
     "19223201",
     "BootNotification",
     {"chargePointVendor": "VendorX", "chargePointModel": "SingleSocketCharger"}
    ]

您的服务器会回应:

[3,
     "19223201",
     {"status":"Accepted", "currentTime":"2013-02-01T20:53:32.486Z", "heartbeatInterval":300}
    ]

从字面上看就是这样

相关问题