2015-10-05 54 views
0

如何讀取SOAP請求的實際xml內容? req.body顯示爲空。我看到的唯一信息是req.headers.soapaction,它給了我一些URL。在node.js中讀取SOAP請求

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

我不知道我的答案是否正確,但我能夠獲取我的數據(這是XML內容)。這是我的解決方案:

var express = require('express'); 
var app = express(); 
... 

var bodyParser = require('body-parser') 
app.use(bodyParser.urlencoded({extended:false})); // Not sure if this is necessary 
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); 
} 

希望這有助於!