读取node.js中的SOAP请求

问题描述 投票:0回答:1

您如何阅读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个回答
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}`));

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.