-->

How do I specify node.exe.config for web app hoste

2019-09-02 01:24发布

问题:

I have a node server deployed to azure and am using Edge.js to make some WCF calls. When I host the server locally, everything works great because I can put the .NET config for the web service calls in node.exe.config located next to my local node.exe as recommended here.

However, this does not seem feasible for a node server hosted on azure. Azure doesn't seem to let user arbitrarily put files on their file systems on whatever machine the user's server happens to be currently running on (which is completely reasonable). Is there a way I can tell edge or node to look for the config in a different location?

回答1:

At first, we should check out whether your WCF calls can be called from public network via the endpoint of the WCF calls.

If we can call the WCF call via the endpoint, we can directly call it in node.js.

Now I have an endpoint of WCF REST service like “http://IP:port/Service.svc/Select?type=-1”, and here is my code snippet about calling this service in node.js:

router.get('/wcfCall', function (req, res, next) {
    var request = require('request');
    var r = request('http://IP:port/Service.svc/Select?type=-1');
    r.on('data', function(data) {
        console.log('decoded chunk: ' + data)
    })
    .on('response', function(response) {
        response.on('data', function(data) {
            console.log('received ' + data.length + ' bytes of compressed data')
        })
    })
})