您如何阅读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?
});
谢谢!
答案 0 :(得分: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}`));
希望这有帮助!