Receiving XML request in strong-soap

Viewed 18

I am currently developing a NodeJS project with strong-soap library to receive and transmit SOAP requests and responses. Before asking question, i want to present code sample to ask my question efficiently.

server.js

//Address of this project is http://localhost:8080
const soap = require('strong-soap');
const http = require('http');
const fs = require('fs');

let myService = { //My SOAP server's service (group of methods)
          Method:
            function(data) //My question literally and directly related with data 
            {
              //... Function content.
            }
};

let xmlFile = fs.readFileSync('sample.wsdl');

let path = '/wsdl';

http.createServer(function (req, res) {
 let soapServer = soap.listen(server, '/wsdl', myService, xmlFile);
}).listen(8080);

Assume that i have a server with codebase which is is seen above. And assume that have another Node.js project (or another .js file) which send request and transmit response from this server.

client.js

const soap = require('strong-soap');
soap.createClient('http://localhost:8080/wsdl', {forceSoap12Headers: true}, function(error, client){
if(error)
  {
     reject(error);
     //res.sendStatus(404);
     //console.log(error);
  }
else{
  client.Method(requestArgs, function(err, result, envelope) { 
//I want to be able to sent an XML data as requestArgs 
    // Result in SOAP envelope body which is the wrapper element.
    // In this case, result object corresponds to GetCityForecastByZIPResponse.
    console.log(JSON.stringify(result));
  }, null, customRequestHeader);
}
});

My question is: how i can send an XML in client.js? Or how i can receive requests in XML format without any problem in server.js? Most probably, i will deal with raw XML requests, and i want to deal with both XML and JSON requests? Help me developers!

0 Answers
Related