New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node-rfc in Angular 6 #83
Comments
|
The node-rfc plugs in seamlessly into any web stack you already use, or plan to use, with Angular 6, or any other frontend. You can continue using all your skills, assets and patterns, only switch the data layer to SAP backend, via node-rfc running in koa, strapi, hapi ... Some examples:
Use the @next release, from napi branch. |
|
@bsrdjan Thanks for your response. With node-rfc, I understand that the data flow or communication works in this order - However, with the use of node-rfc, just ping your thoughts on how we can make this connectivity work - Asking the same bcz Angular framework and its corresponding frontend server supports the installation of node modules and its about how we can make node-rfc node module work on this frontend framework. The objective is to ensure connectivity to a SAP system directly from a browser by entering the required credentials with the required permissions. |
|
The node-rfc node module provides JavaScript bindings for SAP NWRFC SDK binaries, which are running at operating system level, on macOS, Windows, Linux etc. Designed for the nodejs platform and depending on SAP NWRFC SDK, the node-rfc can't work in web browsers but why would you use the node-rfc at all in "direct" scenario? If the objective is connecting web browsers direct to SAP ABAP system, ABAP data can exposed as ODATA or SOAP services, or serialised to JSON and exposed as URL (Google for "ABAP RFC JSON" finds many examples like JSON Adapter for ABAP Function Modules, One more ABAP to JSON Serializer and Deserializer ...). Why the direct connection, bypassing the frontend server, is needed in your scenario, solving which problem? |
|
Thanks again @bsrdjan ! Well, even if it works on the frontend server, its fine - The objective is to achieve client side connectivity with the SAP system, upon entering the system credentials by a user having required permissions. Angular/React(frontend server) <-> SAP system And does not want use the approach of data getting exposed as ODATA or SOAP services bcz it requires certain configurations on the SAP system. As mentioned earlier, the connectivity has to be direct without any configurations on the SAP system and only by just the entering the credentials of the SAP system similar to SAP GUI. It has to be simple, secured and this approach of getting connected from a client side architecture through browser or some other mechanism would be more seamless. Kindly share your thoughts on how we can achieve the same. |
|
The only addition to examples from the first comment, is that connection parameters are not hardcoded. Here one example of the plain user / password authentication. The frontend server serves the logon form and credentials are passed from Angular to frontend server: Angular frontend submit() {
let credentials = { user: this.username, passwd: this.password };
this.http
.fetch("/api/logon", {
method: "post",
body: json(credentials),
//mode: 'cors',
headers: this.httpConfig,
credentials: "include"
})
.then(response => response.json())
.then(resp => {
console.log("response", resp);
});
}The frontend server parses the credentials, opening the connection, which can be reused for subsequent calls: Koa server const Koa = require("koa");
const bodyParser = require("koa-body-parser");
const app = (module.exports = new Koa());
SERVERPORT = 3000;
const rfcClient = require("node-rfc").Client;
const ABAPSystem = {
user: "***",
passwd: "***",
ashost: "10.68.110.51",
sysnr: "00",
client: "620",
lang: "EN"
};
var client;
app.use(bodyParser());
app.use(async (ctx, next) => {
await next();
if (ctx.url === "/logon") {
const payload = ctx.request.body;
ABAPSystem.user = payload.user;
ABAPSystem.passwd = payload.passwd;
client = new rfcClient(ABAPSystem);
return client
.open()
.then(() => {
ctx.response.body = { alive: client.isAlive };
})
.catch(err => {
ctx.response.body = err;
});
} else if (ctx.url === "/user") {
return client
.call("BAPI_USER_GET_DETAIL", { USERNAME: client.connectionInfo.user })
.then(result => {
ctx.response.body = result;
})
.catch(err => {
ctx.response.body = err;
});
}
});
const server = app.listen(SERVERPORT, () => {
console.log(`Server listening on port: ${SERVERPORT}`);
});
if (!module.parent) module.exports = server;Development server proxy can be set for example like (Webpack): proxy: {
"/api": {
"target": "http://localhost:3000",
"pathRewrite": { "^/api": "" }
}The plain user / password authentication is nice for testing and in production more secure methods should be used, like SNC with X509 for example - see Authentication for more details. |
|
Was the example helpful ? Shall we close the issue? |
|
Thanks @bsrdjan for the support !! I tried with your examples. It seems to be working with a backend-server bound framework. The one which Im anticipating is to work in a completely frontend based framework. In fact, I tried bundling the node-rfc files using browserify and webpack. Still, that does not seem to be working. Objective is to connect onto client-side SAP ERP system from a frontend(browser) based framework that works in client-side network with the respective credentials entered by the client-side user in the respective web app. To put that simple, it must completely work through the presentation layer. Maybe, we can also try a Chrome based plugin/extension if this working is not possible on a native stack. Kindly share your thoughts in this regard. Thanks |
|
I don't see that technically possible. The node-rfc is written in C++ and compiled into nodejs binary extension, the The node-rfc has also a thin JavaScript API on top of The rather theoretical possibility for achieving the "frontend-only" objective, would be making the node-rfc platform independent and independent of SAP NWRFC SDK. That would require re-implementing the SAP NWRFC SDK C++ functionality in node-rfc plain JavaScript. That is technically possible but as a bigger development of the completely new node-rfc. Beside technical aspects, I am really curious about envisioned advantages of the frontend-only, "direct" approach, without the server component, because I can't find any? Having a server component makes so many scenarios easier and possible and I wonder what the "frontend-only" benefit could be? You may also contact me per Email, if easier so. |
|
Personally, I'd be concerned about the security implications of a frontend only solution. |
|
Right, the security and SNC would be an issue as well. The "web stack", comprising of web browser, web server, application server (Java, nodejs, Python ...) and the backend (the database or SAP ERP ABAP system) is a kind of web development informal best practice, established over the last 15-20 years. "Invented" before cloud, it works on cloud as well, supporting in a simplest possible way all kinds of new challenges, like isomorphic or progressive web applications, offering diverse parallelisation, caching or scalability patterns. Mature and rich server ecosystems (Java/node/Python ...) have components for practically anything one web application might need. With the "direct", frontend to ABAP model, all that is getting lost and I would like to better understand the benefits of the direct model, which could justify the node-rfc re-write for example. |
|
At first, thanks for your time in jotting down the response. Well, I am aware to certain extent of the above mentioned aspects on technical, security and business implications. On the objective of this requirement, can we have this discussion in mail as you suggested ? And if yes, share your e-mail please. And, is it possible to bundle the libraries and develop the same as a Chrome based plugin/extension using electronjs or other frameworks and have it as a on-premise app that works on the client-side completely. Thanks |
|
sorry, thought my Email is visible in profile but obviously not any more. Here it is: srdjan.boskovic@sap.com |
|
WASM would make the scenario technically possible. |
|
Hello @bsrdjan Thats good to see. Thanks for the info as well. Thanks |
|
Hi @koderkool, I don't have any running example, also not for browser plugin/extension or electron. Consider WASM rather a long-term path. Still missing a convincing business case for the direct browser/ABAP integration (also WASM respects the same-origin policy...), I don't experiment much with client platforms but these examples might help: Running native code in electron..., Using webassembly for a nodejs native addon ... |
@bsrdjan
Any suggestions for making the node-rfc library to work in Angular 6 (with the node modules and dll files loaded) ?
The objective is to make the node-rfc library to work in a browser. Feel free to share your thoughts.
Thanks !
The text was updated successfully, but these errors were encountered: