【问题标题】:read SOAP request in node.js在 node.js 中读取 SOAP 请求
【发布时间】:2015-10-05 22:54:21
【问题描述】:
您如何读取 SOAP 请求的实际 xml 内容? req.body 似乎是空的。我看到的唯一信息是req.headers.soapaction,它给了我一些网址。
app.use(function(req, res, next){
console.log(req.headers.soapaction); // this gives some url
console.log(req.body); // but nothing here.. how can i see the xml content?
});
谢谢!
【问题讨论】:
标签:
xml
node.js
express
soap
soap-client
【解决方案1】:
我不知道我的回答是否正确,但我能够获取我的数据(即 XML 内容)。这是我的解决方案:
const express = require('express');
const app = express();
...
const bodyParser = require('body-parser');
app.use(bodyParser.text({type:'text/*'})); // reads the body as text (see Express 4 API docs)
...
app.get((req,resp) => {
var body = req.body; // Should be a giant object of characters
var data = JSON.stringify(body); // Put all the characters into a single string
console.log("Data: " + data);
});
app.listen(PORT, () => console.log(`App running on ${PORT}`));
希望这会有所帮助!