Nodejs using "url + xml" Data post request And get Response THis is MY PHP Code : -
<?php $request= '<Request><Head><Username>0f4dd0ce77dc24f9f5e9057b6b978621</Username><Password>v0Auj1TCfQdD</Password><RequestType>HotelSearch</RequestType></Head><Body><CityId>248245</CityId><CheckInDate>2016-05-05</CheckInDate><CheckOutDate>2016-05-07</CheckOutDate><Rooms><Room><NumAdults>2</NumAdults></Room></Rooms><Nationality>US</Nationality><Currency>USD</Currency></Body></Request>' ; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://xml.travellanda.com/xmlv1"); curl_setopt($ch, CURLOPT_TIMEOUT, 180); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml' => $request)); $response = curl_exec($ch); $info = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo $response; ?> Its work Fine. As the Same way i do in Node js. MY Nodejs Coding : - exports.Travel = function(req, res){ var https = require('https'); var term = req.params.name; var request = require('request'); var body = '<?xml version="1.0" encoding="utf-8"?><Request><Head><Username>0f4dd0ce77dc24f9f5e9057b6b978621</Username><Password>v0Auj1TCfQdD</Password><RequestType>HotelSearch</RequestType></Head><Body><CityId>248245</CityId><CheckInDate>2016-05-05</CheckInDate><CheckOutDate>2016-05-07</CheckOutDate><Rooms><Room><NumAdults>2</NumAdults></Room></Rooms><Nationality>US</Nationality><Currency>USD</Currency></Body></Request>' var options = { url: 'https://xml.travellanda.com/xmlv1', port: 443, method: 'POST', body: body, strictSSL: false, headers: { Accept: 'text/xml', 'Content-Length': Buffer.byteLength(body) }, }; options.agent = new https.Agent(options); request.get(options, function(response){ //console.log("options.agent..", response); var buffer = response.cert.raw; const buf = new Buffer(buffer, 'utf8'); const json = buf.toString('UTF-8',0,5) //JSON.stringify(buf); res.send(json); const copy = JSON.parse(json, (key, json) => { return json && json.type === 'Buffer' ? new Buffer(json.data) : json; }); }) } it Show the Error Hostname/IP doesn't match certificate's altnames Please Help me -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/1991393d-9fee-4ebf-af4a-4e30586417a0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
