Hello,
i read the software blog from David Russo about node.js. If i correctly understand him, node.js is a new feature for the iSeries, coming with TR9. But what can i do with this? We wish to implement webservices which read and write data from and to the iSeries. Probably we will implement this on a linux server in java, using the IBM toolbox. Can nodes.js be an alternative to this? Is is possible to call RPG programs from nodes.js? Or can i access databases on the iSeries with node.js?
Or is there a possibility to use node.js to improve ProfoundUI screens?
Sorry for my dilettantish questions. But in the blog i read that David is very enthusiastic about node.js. But i didn't understand how is can help me with my in my iSeries aplications.
Dieter
Your Latest Software Block for Node.js
-
- Experienced User
- Posts: 122
- Joined: Tue May 22, 2012 6:45 am
- First Name: Dieter
- Last Name: Schröder
- Company Name: Ecclesia Holding GmbH
- State / Province: Outside Canada/USA
- Country: Germany
- Contact:
- Glenn
- Profound Logic Staff Member
- Posts: 124
- Joined: Mon Apr 14, 2014 4:08 pm
- First Name: Glenn
- Last Name: Hopwood
- Company Name: Profound Logic Software
- State / Province: Ohio
- Country: United States
- Contact:
Re: Your Latest Software Block for Node.js
Dieter,
I'm sure some of our other developers will respond with more information but, basically, the answer to all of your questions is 'yes'. Node.js (along with some node packages created by IBM and others) can do all the things you asked and more.
Here's a link to some more IBM I specific technical information and sample code: http://yips.idevcloud.com/wiki/index.php/NodeJs/NodeJs.
Glenn
I'm sure some of our other developers will respond with more information but, basically, the answer to all of your questions is 'yes'. Node.js (along with some node packages created by IBM and others) can do all the things you asked and more.
Here's a link to some more IBM I specific technical information and sample code: http://yips.idevcloud.com/wiki/index.php/NodeJs/NodeJs.
Glenn
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Your Latest Software Block for Node.js
Hi Dieter,
My excitement about Node.js is because I see a lot of possibilities for leveraging it to improve Profound Logic's tools going forward. Right now we are still at the point of exploring options and we have no firm plans with it, although we have found several potential uses for it in Profound UI. I can't say anymore than that at this point, but we'll certainly make announcements on any firm plans.
Some general information...
Node.js can certainly be used to implement web services using data from DB2 on IBM i. Node.js was originally designed for Unix/Linux-type systems running on common CPU architectures like Intel, etc. IBM has been supporting a port for POWER architecture for some time, but up until now the port was only compatible with the AIX operating system. IBM now provides an IBM i-compatible version that installs as a normal licensed program (RSTLICPGM) and runs in PASE. It requires at minimum IBM i 7.1, and there are other pre-requisites. See here for complete installation details:
https://www.ibm.com/developerworks/comm ... ge/Node.js
I found that originally the information on pre-requisites was not complete, I'm not sure if this has been updated or not. Start by using the information on pre-requisites given at that page and if you have any problems after that I'd recommend installing any/all PTFs available for licensed programs 5733-SC1 and 5733-OPS.
Node.js can be described briefly like this...
It is a server-based JavaScript runtime environment. The Node.js program runs in a continuous loop and your programs attach asynchronous event handlers for I/O tasks (like reading file data, etc.). The Node.js program just kicks off your event handlers as needed until there is nothing left to do, at which point it quits.
This design means that a Node.js process can make extremely efficient use of system resources because it can always be "doing something", rather than waiting around on I/O. This makes it extremely well suited for multi-user networked applications like web services. There is a huge variety of free and open source packages you can run in Node.js through the NPM tool, like an HTTP server, web services frameworks, etc.
IBM has also provided modules which allow for connecting to DB2 on i, and for interacting with native OS objects through XML Services. See here:
https://www.ibm.com/developerworks/comm ... ge/Node.js
You can find tutorials on the web for setting up REST services, and should be able to put something together with this on IBM i just as easily as on Linux, and just as easily (or more) than using Java.
Is it better to run it on IBM i or Linux? To use Node.js vs. Java for your web services? I don't think there is a "correct" answer there, it depends on your environment, your team's skillset, preferences, etc. But this is another option that you have now.
My excitement about Node.js is because I see a lot of possibilities for leveraging it to improve Profound Logic's tools going forward. Right now we are still at the point of exploring options and we have no firm plans with it, although we have found several potential uses for it in Profound UI. I can't say anymore than that at this point, but we'll certainly make announcements on any firm plans.
Some general information...
Node.js can certainly be used to implement web services using data from DB2 on IBM i. Node.js was originally designed for Unix/Linux-type systems running on common CPU architectures like Intel, etc. IBM has been supporting a port for POWER architecture for some time, but up until now the port was only compatible with the AIX operating system. IBM now provides an IBM i-compatible version that installs as a normal licensed program (RSTLICPGM) and runs in PASE. It requires at minimum IBM i 7.1, and there are other pre-requisites. See here for complete installation details:
https://www.ibm.com/developerworks/comm ... ge/Node.js
I found that originally the information on pre-requisites was not complete, I'm not sure if this has been updated or not. Start by using the information on pre-requisites given at that page and if you have any problems after that I'd recommend installing any/all PTFs available for licensed programs 5733-SC1 and 5733-OPS.
Node.js can be described briefly like this...
It is a server-based JavaScript runtime environment. The Node.js program runs in a continuous loop and your programs attach asynchronous event handlers for I/O tasks (like reading file data, etc.). The Node.js program just kicks off your event handlers as needed until there is nothing left to do, at which point it quits.
This design means that a Node.js process can make extremely efficient use of system resources because it can always be "doing something", rather than waiting around on I/O. This makes it extremely well suited for multi-user networked applications like web services. There is a huge variety of free and open source packages you can run in Node.js through the NPM tool, like an HTTP server, web services frameworks, etc.
IBM has also provided modules which allow for connecting to DB2 on i, and for interacting with native OS objects through XML Services. See here:
https://www.ibm.com/developerworks/comm ... ge/Node.js
You can find tutorials on the web for setting up REST services, and should be able to put something together with this on IBM i just as easily as on Linux, and just as easily (or more) than using Java.
Is it better to run it on IBM i or Linux? To use Node.js vs. Java for your web services? I don't think there is a "correct" answer there, it depends on your environment, your team's skillset, preferences, etc. But this is another option that you have now.
-
- Experienced User
- Posts: 122
- Joined: Tue May 22, 2012 6:45 am
- First Name: Dieter
- Last Name: Schröder
- Company Name: Ecclesia Holding GmbH
- State / Province: Outside Canada/USA
- Country: Germany
- Contact:
Re: Your Latest Software Block for Node.js
Hello Glenn, hello David.
Thank you very much for your extremely interesting answers. I will have a look onto the links you have posted. Also i will discuss the new possibilitys with my colleagues. In our company we have programmers with Java skills and Javascript skills (and of course RPG skills). So i think, we will discuss what might be the best solution for us.
Dieter
Thank you very much for your extremely interesting answers. I will have a look onto the links you have posted. Also i will discuss the new possibilitys with my colleagues. In our company we have programmers with Java skills and Javascript skills (and of course RPG skills). So i think, we will discuss what might be the best solution for us.
Dieter
-
- Profound User
- Posts: 39
- Joined: Mon Aug 29, 2011 10:53 pm
- First Name: Paul
- Last Name: Foster
- Company Name: GRI Group Ltd
- Country: Hong Kong
- Location: Hong Kong
- Contact:
Re: Your Latest Software Block for Node.js
Dieter,
We do a lot of providing and consuming web services using mainly RPG (occasionally some Zend PHP). Most of it has been developed from what Scott has published in the public domain, I'd be happy to send you some examples and code if you're interested. For writing json we use 100% RPG - some is hard coded (ie, add the { " : } etc as literals), some use YAJL.
node.js looks good for the future, but it will be a while for us as we're still on 6.1.
Paul
We do a lot of providing and consuming web services using mainly RPG (occasionally some Zend PHP). Most of it has been developed from what Scott has published in the public domain, I'd be happy to send you some examples and code if you're interested. For writing json we use 100% RPG - some is hard coded (ie, add the { " : } etc as literals), some use YAJL.
node.js looks good for the future, but it will be a while for us as we're still on 6.1.
Paul
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Your Latest Software Block for Node.js
Thanks, Paul. You're right, those are all perfectly good solutions for Web Services, too. As long as you are separating the data access and business logic from the rest of the process, it's hard to go wrong, really.
Dieter,
There are tons of options for web services, some other approaches:
* Profound UI Universal Display files can be used to serve up XML and JSON documents very easily for REST-style web services. All Profound UI customers have access to the Universal Display File editor and Handler at no additional charge.
* IBM includes integrated web services for ILE, available to all IBM i customers at no additional charge. This was limited to SOAP in older releases, but IBM has recently implemented REST support, as well.
Dieter,
There are tons of options for web services, some other approaches:
* Profound UI Universal Display files can be used to serve up XML and JSON documents very easily for REST-style web services. All Profound UI customers have access to the Universal Display File editor and Handler at no additional charge.
* IBM includes integrated web services for ILE, available to all IBM i customers at no additional charge. This was limited to SOAP in older releases, but IBM has recently implemented REST support, as well.
-
- Experienced User
- Posts: 122
- Joined: Tue May 22, 2012 6:45 am
- First Name: Dieter
- Last Name: Schröder
- Company Name: Ecclesia Holding GmbH
- State / Province: Outside Canada/USA
- Country: Germany
- Contact:
Re: Your Latest Software Block for Node.js
Hello David, hello Paul.
Thank you for your answers. I must say, that we are not absolut beginners with webservices. We have implented a few webservices with pure RPG. We have created our own tools to create JSON objects. We also use parts the HTTPAPI lib from Scott Klement e.g. to get the url.
But even if it possible to write webservices in pure RPG we think that this is unhandy. The part to send information from the iseries to the PC is the simple part, because all you have to do is to read and interpret the url and to write JSON strings. But i think it is a lot more effort to get data from the PC and store this data in the iseries. (Please excuse my poor English). If the PC sends complex JSON objects to store them in the iseries we have to interpret the received JSON strings. I have no good idea how to do this with comfortable generic tools in RPG. In RPG there are limitations of the size of data structures. Also we don't have objects or dynamic arrays.
So i think, we can write webservices to read and send data purely in RPG. But i fear that this is very dificult in comparison to other programming languages like Java or Javascript.
We have decided to do the communication between PC and iseries completely with webservices in the future. So we will have to write not only a few webservices. We will have to create and maintain many webservices. So we are looking for the best solution to do this. The decision which programming language we will use is not over yet.
Paul, i would be glad if you couldt send me a few examples and code snippets. So i can compare our code with your code. Maybe you have ideas which are new for us. I will send you my email adress via a private message.
Thank you in advance.
Dieter
Thank you for your answers. I must say, that we are not absolut beginners with webservices. We have implented a few webservices with pure RPG. We have created our own tools to create JSON objects. We also use parts the HTTPAPI lib from Scott Klement e.g. to get the url.
But even if it possible to write webservices in pure RPG we think that this is unhandy. The part to send information from the iseries to the PC is the simple part, because all you have to do is to read and interpret the url and to write JSON strings. But i think it is a lot more effort to get data from the PC and store this data in the iseries. (Please excuse my poor English). If the PC sends complex JSON objects to store them in the iseries we have to interpret the received JSON strings. I have no good idea how to do this with comfortable generic tools in RPG. In RPG there are limitations of the size of data structures. Also we don't have objects or dynamic arrays.
So i think, we can write webservices to read and send data purely in RPG. But i fear that this is very dificult in comparison to other programming languages like Java or Javascript.
We have decided to do the communication between PC and iseries completely with webservices in the future. So we will have to write not only a few webservices. We will have to create and maintain many webservices. So we are looking for the best solution to do this. The decision which programming language we will use is not over yet.
Paul, i would be glad if you couldt send me a few examples and code snippets. So i can compare our code with your code. Maybe you have ideas which are new for us. I will send you my email adress via a private message.
Thank you in advance.
Dieter
-
- Experienced User
- Posts: 122
- Joined: Tue May 22, 2012 6:45 am
- First Name: Dieter
- Last Name: Schröder
- Company Name: Ecclesia Holding GmbH
- State / Province: Outside Canada/USA
- Country: Germany
- Contact:
Re: Your Latest Software Block for Node.js
David,
you wrote that there a 2 more approached for webservices. Your suggestion of UI Universal Display files only helps if i want to write JSON data. I think there is no support to read JSON data. Or am i wrong? I asked this question recently and Scott Klement gave me the answer that there is no support for reading JSON.
I am not sure what you mean with your second approach, the "integrated web services for ILE". In a training one year ago the trainer could not show a practicable solution for integrated webservices. The solution he showed, was only operable by mouse clicking. There was not possibility to script the configuration. Do you know if there is an enhancement now?
Dieter
you wrote that there a 2 more approached for webservices. Your suggestion of UI Universal Display files only helps if i want to write JSON data. I think there is no support to read JSON data. Or am i wrong? I asked this question recently and Scott Klement gave me the answer that there is no support for reading JSON.
I am not sure what you mean with your second approach, the "integrated web services for ILE". In a training one year ago the trainer could not show a practicable solution for integrated webservices. The solution he showed, was only operable by mouse clicking. There was not possibility to script the configuration. Do you know if there is an enhancement now?
Dieter
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Your Latest Software Block for Node.js
Scott was correct -- as it stands now Universal Display File programs can read only read input formatted as URL-encoded name/value pairs from the query string and POST. The programs can also look at the URL that was used to make the request. UDF programs can output either JSON or XML.
But, currently the UDF programs can't read raw JSON or XML documents from the POST. It's possible we could make an enhancement here, though, perhaps we could make this data available to the UDF program in another way.
As for the IBM integrated web services, I'm not sure if there is a way to configure those outside of the IBM Web Admin GUI. That would be a good question for your trainer, or perhaps IBM support could tell you.
But, currently the UDF programs can't read raw JSON or XML documents from the POST. It's possible we could make an enhancement here, though, perhaps we could make this data available to the UDF program in another way.
As for the IBM integrated web services, I'm not sure if there is a way to configure those outside of the IBM Web Admin GUI. That would be a good question for your trainer, or perhaps IBM support could tell you.
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Your Latest Software Block for Node.js
Actually, it seems we thought of this case already and the UDF program does have access to the raw input data through an environment variable that is set in the job. It doesn't seem that this feature is documented, I'll have to fix that...
Are you familiar with accessing environment variables using the system's 'getenv()' function? If so, you can get a pointer to the POST or PUT data very easily.
The procedure:
1. Start by checking the REQUEST_METHOD environment variable. If this is set to 'POST' or 'PUT' then...
a. Input data is set in environment variable PUI_UNIVERSAL_INPUT. The data is encoded in UTF-8.
b. Byte length of data is given by environment variable CONTENT_LENGTH
2. Pass pointer to data to document parser, i.e. Scott's YAJL port for JSON, or RPG's built-in functions for XML documents.
Are you familiar with accessing environment variables using the system's 'getenv()' function? If so, you can get a pointer to the POST or PUT data very easily.
The procedure:
1. Start by checking the REQUEST_METHOD environment variable. If this is set to 'POST' or 'PUT' then...
a. Input data is set in environment variable PUI_UNIVERSAL_INPUT. The data is encoded in UTF-8.
b. Byte length of data is given by environment variable CONTENT_LENGTH
2. Pass pointer to data to document parser, i.e. Scott's YAJL port for JSON, or RPG's built-in functions for XML documents.
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest