AnsweredAssumed Answered

GeoEvent connectors (setting up a mockup)

Question asked by Satwik95 on Sep 12, 2019

I am a beginner and any help will be very much appreciated.

I want to set input and output connectors using the GeoEvent manager such that the input side receives text in XML format, and the output connector sends the converted JSON.

Using the manager I have set up a GeoEvent service where I have set the input and output connectors to different ports on the localhost. (Probably not the right way to go about, will try to set up servers and try, however just want to know if it's possible doing this simple way)

For example: input connector: https://<localhost ip>:3000/ (this returns XML)

output connector: https://<localhost ip>:2121/ (This will log the JSON on receiving from the output connector)

1. I need help in selecting the right connectors (poll XML from an external website or rest endpoint)

2. Should I make any changes to my js code?

3. Output connector side: Is the JSON sent in the body of the POST request to the target link?

 

```
//-----------XML Side------------

const express = require('express');
const srv = express();
const port = 3000;
let xml = `<note>
                     <to>Satwik</to>
                     <from>Harry</from>
                     <heading>Hi</heading>
                     <body>Sup, let us catchup.</body>
               </note>`

srv.get('/', (req, res) => {
   res.set('Content-Type', 'text/xml');
   res.send(xml);
});
srv.listen(port);

 

//----------------JSON Side---------

const express = require('express');
const srv = express();
const port = 2121;
const fs = require('fs');

const parser = require('body-parser');
srv.use(parser.urlencoded(express.json()));
srv.use(parser.urlencoded({extended:true}));

srv.post('/', (req, res) => {
   let jS = JSON.string(req.body);
   fs.writeFile("xml2js.json", jS);
   //fs.writeFile("xml2js_text.txt", jS);
   console.log(req.body);
});

srv.listen(port);

```

 

Update: Now, I have set up an AWS EC2 instance, and running the server there. On starting the input connector getting this error: 'Failed to get a response from <url>'. 

 

Outcomes