How to Use the Wurfl onsite java in Node.js app/project

120 Views Asked by At

We've an already implemented WURFL onsite Java app (berryapp implemented using maven/servlet) which we use for all our Java apps, just giving a call to that app in all other apps. Since it is Java based it works well in all other Java apps that call it.

I want to use the same app in my Node.js app (it doesn't have any Java). How can I call the (berryapp/wurfl app) in my node.js?

2

There are 2 best solutions below

2
Luca P. On

If I understand the question correctly, this may be as simple as creating a JSP page or a servlet that user the WURFL API to return the data in JSON format, so Node.js can pick it up.

Also note that a Node.js product is available commercially from the same company.

2
danday74 On

Does your Java app expose an HTTP interface? If so, Node can talk to it over HTTP.

If not, you can set up an HTTP API for the Java app. There is prob a Java library out there that will simplify this process. Sadly, I know Node, not Java so I can't recommend one but I regularly interact with Java apps from Node over HTTP and our Java developers use Spring Boot to expose an HTTP interface. Sadly, I don't know much about Spring Boot. But there are undoubtedly many options in the Java world for exposing an HTTP API.

EDIT:

You said you are new to Node.js (I don't know how new). I will assume you know nothing.

(Git Bash allows you to run Linux commands on Windows)

Run the following commands in Git Bash or via your Linux / Mac terminal:

mkdir nodeFun
cd nodeFun
touch index.js
npm init

npm init will ask you a lot of questions. Just press enter on ALL questions. This will create a file called package.json

Now choose an npm module to make HTTP requests. You have so many choices. Some of the most popular ones are:

https://www.npmjs.com/package/request

https://www.npmjs.com/package/axios (I will use this in the example below)

When you have chosen, install the chosen module with the following command:

npm install -S axios

Now in your index.js file:

const axios = require('axios')
// You axios code here to make HTTP requests to your Java API - see the axios documentation for details of how to make an HTTP request with axios

Finally, when you have finished writing index.js you can run it from the command line with:

node index # you must be in the nodeFun directory