var http = require('http'),
httpProxy = require('http-proxy'),
soap = require('soap-server'),
util = require('util');
var host = {
address:'127.0.0.1',
port:{
proxy:1337,
server:1338
},
serverUri:function() {
return util.format('http: },
proxyUri:function() {
return util.format('http: }
};
var proxy = httpProxy.createProxyServer({});
var server = http.createServer(function(req, res) {
console.log('Request', JSON.stringify(req.headers, true, 2));
req.on('data', function (data) {
console.dir( data.toString() );
});
proxy.web(req, res, { target: host.proxyUri() } );
});
proxy.on('proxyRes', function (proxyRes, req, res) {
proxyRes.on('data', function (data) {
console.dir( data.toString() );
});
console.log('Response', JSON.stringify(proxyRes.headers, true, 2));
});
function MyTestService(){
}
MyTestService.prototype.test1 = function(myArg1, myArg2){
console.log( "test1 ", "" + myArg1, "" + myArg2);
return myArg1 + myArg2;
};
var soapServer = new soap.SoapServer();
var soapService = soapServer.addService('testService', new MyTestService());
console.log("Proxy listening on port: ", host.port.proxy);
server.listen(host.port.proxy);
soapServer.listen(host.port.server, host.address);
console.log('Server running at ', host.port.server);
console.log("wsdl: ",host.proxyUri(), '/testService?wsdl');