Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Push XML Events To a NodeJS Server?

Push XML Events To a NodeJS Server?


I need to Push Xml Events from some server to a NodeJS server.

I thought the best way to do so it to create a NodeJS based web service (WSDL, SOAP, XML... according to the standards) but i didn't find any module.

I thought about as well but i think it is relevant only when the communication includes a browser...

Any ideas?


Problem courtesy of: hdmi3killer


Well, the good news is Node gives you a great deal of flexibility, but doesn't always have the libraries to implement things like this.

So, the first question is does the other side already exist? As in, why XML?

Assuming it doesn't but you do want to use XML, two options include HTTP (REST) or TCP sockets, both of which can be trivally implemented in Node.

First, HTTP:

I'll be using express, though you can use another framework or just http if you prefer.

var express = require('express')
var app = express.createServer();
var notQuiteBasic = function(req, res, next) {
    if (req.headers['Authentication']) {
        req.authenticated = true;

app.use(notQuiteBasic);'/xml', function(req, res) {
    if (req.authenticated) {
        processXml(req.body, function() {

And tcp:

var socket = require('socket');
var server = socket.createServer();
server.on('data', function (data) {
    /* TODO: check envelope auth */
server.listen(8222, '');
Solution courtesy of: Timothy Meade


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Push XML Events To a NodeJS Server?


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription