TypeError:第一个参数必须是字符串或Buffer - Nodejs

时间:2018-03-12 12:09:43

标签: node.js

我正在使用soap-wsdl服务并尝试将查询结果发送到前端服务角度4.一旦我编译它,我从服务器端收到以下错误。

我在here中经历了一些解决方案。然后我在回调中声明了我的 res.end(test1),但我仍然遗漏了什么?



var soap = require('strong-soap').soap;
var http = require('http');
var fs = require('fs');

function getQuery() {
  var response = db.query(aqlQuery `
                 LET startVertex = (FOR doc IN spec
                 FILTER doc.serial_no == '"123456abcde"'
                 LIMIT 2
                 RETURN doc
                 )[0]

                FOR v IN 1 ANY startVertex belongs_to
                RETURN v.ip`, {
    bindVar1: 'value',
    bindVar2: 'value',
  });
  console.log("response is " + response);
  return response;

}
var checkUserName = {
  CheckUserName_Service: {
    CheckUserName_Port: {
      checkUserName: function(args, cb, soapHeader, req) {
        var query = getQuery();
        return query.then(function(response) {
          console.log("response is " + JSON.stringify(response._result));

          var soap_msg = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:CheckUserNameService">' +
            '<soapenv:Header/>' +
            '<soapenv:Body>' +
            '<urn:CheckUserNameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
            '<status xsi:type="xsd:string">' + JSON.stringify(response._result) + '</status>' +
            '</urn:CheckUserNameResponse>' +
            '</soapenv:Body>' +
            '</soapenv:Envelope>';
        });
   }
  }
};
var wsdl = require('fs').readFileSync('check_username.wsdl', 'utf8');
var requestCont = {
  requestHandler: function(req, res) {
    var test1 = checkUserName.CheckUserName_Service.CheckUserName_Port.checkUserName('OMG', null, null, null);

    console.log(test1);
    res.end(test1);
  }
};
server = http.createServer(requestCont.requestHandler);

server.listen(8000);
soap.listen(server, '/var/www/html/test/', checkUserName, wsdl);
&#13;
&#13;
&#13;

enter image description here

0 个答案:

没有答案