问题
I tried to bring an old phonegap 1.0 app into VS tool for Apache Cardova. It calls an old WCF XML web service. When I ran the app in Ripple Emulator using local proxy, I got 400 error from the WCF web service. After some digging around, I found the problem in C:\Users\user_name\AppData\Roaming\npm\node_modules\vs-mda\node_modules\ripple-emulator\lib\server\proxy.js line 85-91:
if (Object.keys(req.body).length > 0) {
if (req.is("json")) {
proxyReqData.body = JSON.stringify(req.body);
} else {
proxyReqData.form = req.body;
}
}
If the request is not json, the code would change it to a form so that an XML web service is not supported by the Ripple proxy. I fixed the code at the place, but it was not picked up by the project build. I also do not have a good way to debug my version of proxy.js. Any suggestion would be appreciated.
回答1:
I figured out the fix myself. The proxy.js that I found is the right location. However, I had to make several changes to proxy.js to make it work with a soap web service. Note that my changes works when you only call soap web services.
Comment out the line with app.use(express.bodyParser()); and replace with it with raw parser in this post: Expressjs raw body
Replace the code block in my question with just:
proxyReqData.form = req.body;
来源:https://stackoverflow.com/questions/29222701/400-error-calling-wcf-web-service-from-ripple-emulator