node.pdf

Upload: ghenno18

Post on 02-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Node.pdf

    1/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/

    Node.js on Azure calling SAP Gateway

    Posted on March 21, 2012

    Its hard to miss the growing excitement around Node.js, a server-side JavaScript

    environment, especially ever since Microsoft supports the Node.js project and even offers

    Node app hosting as a service on Windows Azure.

    I was eager to get a first hands-on with Node on Azure, so in this post we are going to build a

    Node.js app running on Windows Azure, accessing SAP business data through SAP

    Gateway. I decided to go for the Cloud all-the-way, so we will develop both a server and

    client (i.e. browser) application in JavaScript using Cloud9,a web based IDE. The browser

    app is based on SAPUI5. It displays a list of Sales Orders and the user can also request an

    overview in Excel, generated on-the-fly on the server. To easily work with the source code of

    the project, we will use a repository on GitHub.

    Here are screenshots of the end result:

    And All That JSJavaScript, Web Apps and SharePoint

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/http://allthatjs.com/http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/
  • 8/10/2019 Node.pdf

    2/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 2

    http://allthatjs.files.wordpress.com/2012/03/snaghtmlcac40b9.png
  • 8/10/2019 Node.pdf

    3/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 3

    So if you are in for some exposure to cutting edge technologies, read on!

    The players

    SAP Gatewayis a SAP server add-on that allows you to access business data in SAP

    systems through OData, an open web protocol for querying and updating data, built on

    common web technologies like HTTP, XML and REST.

    SAPUI5(officially known as UI development toolkit for HTML5) is a JavaScript library,

    currently in Beta, to build HTML5 apps.

    Node.jsis a server platform that is quickly gaining popularity. It is built on Chromes V8

    JavaScript runtimeand allows you to create server applications in JavaScript. Node.js uses an

    event-driven, non-blocking I/O model that makes it lightweight and efficient.

    Cloud9is a web-based IDE + node.js runtime environment offered as a service (partially open

    sourced). In Cloud9 you can develop, debug and test node.js applications, all from within your

    browser. Cloud9 can use a GitHub repository to manage and share the source code. Once

    http://c9.io/http://code.google.com/p/v8/http://nodejs.org/http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/20a34ae7-762d-2f10-c994-db2e898d5f70http://www.odata.org/http://scn.sap.com/community/netweaver-gatewayhttp://allthatjs.files.wordpress.com/2012/03/snaghtmlb1e5875.png
  • 8/10/2019 Node.pdf

    4/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 4

    you have completed your application, you can deploy the application to Windows Azure.

    Windows Azureis Microsofts cloud platform. One of the services is hosting a Node.js

    application in a scalable environment.

    GitHubhosts source code repositories,using the Git version control system. GitHub offers

    public and private repositories. To work with GitHub, you need to use Git client software.

    The Big Picture

    Before we go into the details, lets sketch how it all fits together:

    For development, well create a code repository on GitHub. This way we can add/update

    source code and resource files both from our local machine (via Git) and on Cloud9. We will

    use the repository to add all SAPUI5 js and css files that are required to our project files. In

    Cloud9 we use a clone of the GitHub repository. This way we can push and pull Cloud9

    project files in and out of the GitHub repository.

    Cloud9 is a fully web-based development environment: developers use a browser to access

    the Cloud9 code editor, system command prompt, debugger, Node.js console output etc. We

    can run a Node.js application directly on the Cloud9 environment and use a special url to

    access the running server app as a (test) user.

    Actually we need 2 applications: a server applicationwhich runson the Node.js server and

    acts as middleman to SAP Gateway (and possibly other data sources) and a client

    application(HTML5, SAPUI5) which runs in the browser, but uses html/css/js files which

    are hostedon the server. It is important to keep these two apart, even if we develop both in

    JavaScript.

    http://allthatjs.files.wordpress.com/2012/03/image5.pnghttps://github.com/http://c9.io/
  • 8/10/2019 Node.pdf

    5/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 5

    The client and server app interact in the following way:

    DISPLAY SALES ORDERS IN DATA TAB LE

    the user starts the app by requesting the server url

    the server sends the client application html file (index.html) which instructs the browser

    to load additional SAPUI5 resource files and the client js code.

    the client app starts up and creates a SAPUI5 OData Model and Data Table to fetch and

    display Sales Order data. The data isnt fetched from the SAP Gateway directly (not

    allowed due to the Same Origin Policy). Instead, the request is sent to the server, which

    forwards it to SAP Gateway. The server acts as a reverse proxy.

    The server passes the OData response from SAP Gateway to the browser. Here, the

    OData feed is parsed using SAPUI5s built in OData support and the extracted data is

    shown in the Data Table.

    DOWNLOAD AS EXCEL

    When the user clicks on Download as Excel button, the client app requests a special

    url from the server.

    This will trigger the server to fetch the Sales Order data from SAP Gateway, parse it (but

    now on the server side!), convert it into an Excel format and return this to the user. The

    user experience is identical to requesting a downloadable file.

    Once we have the application working in the Cloud9 environment, we can request deployment

    to Windows Azure. Cloud9 will generate configuration files, package the apps, upload and

    deploy to Azure.

    Caveats:

    This demo project involves quite some platforms and services. Within the scope of this

    blog post it is not feasible to provide a very detailed, click-by-click walk-through. Instead

    I will refer to tutorials for the respective services which contain detailed instructions and I

    will point out the main route and highlights along the way.

    I recommend that you use Safari, Chrome or Firefox on GitHub and Cloud9. IE support

    is lagging (GitHub) or non-existent (Cloud9).

    Step 1: Create a GitHub repository

    First we need to create a repository on GitHub to manage and share our source code across

    environments.

    1. Sign-up with a (free) account for GitHub. A free account lets you create public

    repositories.

    2. Follow the instructions on Set up Gitto install Git local software and set up SSH keys

    3. Create a repositoryon GitHub. Well assume it is named: NODEJS_SAPGW

    http://help.github.com/create-a-repo/http://help.github.com/win-set-up-git/https://github.com/
  • 8/10/2019 Node.pdf

    6/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 6

    4. Clone the repository to local machine

    5. Try out pushing and pulling content from your local machine into the repository until you

    become familiar with the process

    Here are the important Git commands you will need:

    I think GitHub is a great tool for developers, so I encourage you to check out the GitHub help

    centerto learn more.about the other features of Git and GitHub. For our demo project the

    above commands are all we need.

    Step 2: Develop on Cloud9

    Now we have a repository on GitHub, we can start a project on the Cloud9 IDE.

    1. Signup on http://c9.io. It is very convenient to signup with your GitHub account. Look for

    the small GitHub icon.

    2. After signup, you will see your GitHub repository (I blurred out my other repositories):

    // Clone repository

    $ git clone [email protected]:[yourname]/NODEJS_SAPGW.git// push contentgit add .git commit -m "Commit message"git push// pull contentgit pull

    http://allthatjs.files.wordpress.com/2012/03/image6.pnghttp://c9.io/http://help.github.com/
  • 8/10/2019 Node.pdf

    7/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 7

    3. Select the repository and click Clone to edit and select Shared Development server.

    4. The Cloud9 environment will make a Clone of the GitHub repository available in your

    Cloud9 environment.

    5. Once the Clone is completed, you see the following screen. Click on Start Editing.

    6. This will bring you into the project environment. Create a folder called Public. This folder

    will contain all the files required for the client application. Add the index.html and app.js

    (described below) and push the changes to GitHub and pull to your local machine. Add

    the SAPUI5 resources on your local working directory and push to GitHub and pull from

    Cloud9. All this pushing and pulling sounds like a workout, but trust me, youll get the

    hang of it!

    Client application

    The client application consists of an index.html file and app.js file and uses SAPUI5 to fetch

    and parse OData and render a data table widget.

    The index.html includes the SAPUI5 core library (which dynamically will load all

    http://allthatjs.files.wordpress.com/2012/03/image8.pnghttp://allthatjs.files.wordpress.com/2012/03/image7.png
  • 8/10/2019 Node.pdf

    8/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 8

    dependencies), the application js file and a placeholder for the data table.

    The app.js contains the client code:

    01020304050607

    08091011121314151617181920

    Node.js calling SAP Gateway

    1234567891011

    12131415161718192021222324

    2526272829303132333435363738

    // Let's define some shortcuts to increase// readability of the codevarODataModel = sap.ui.model.odata.ODataModel, TextView = sap.ui.commons.TextView, Label = sap.ui.commons.Label, DataTable = sap.ui.table.DataTable, Toolbar = sap.ui.commons.Toolbar, Button = sap.ui.commons.Button, Column = sap.ui.table.Column, Right = sap.ui.commons.layout.HAlign.Right, Begin = sap.ui.commons.layout.HAlign.Begin,

    SelectionMode = sap.ui.table.SelectionMode;// Specify the SAP Gateway SalesOrder service as an OData model.// Please note: we do not connect directly to SAP Gateway (no host spe// Instead, the calls are made to the Node.js server,// which will proxy the calls to SAP GW// This way, we comply with Same Origin Policy of the browser.varsalesOrderService = "/sap/opu/sdata/IWFND/SALESORDER",

    // SAP Gateway only supports XML, so don't use JSON asJson = false, salesOrderModel = newODataModel(salesOrderService, asJson),

    salesOrderCollection = "SalesOrderCollection";// Create a button to request an Excel workbook from servervarbutton = newButton({ text: "Download as Excel", icon: 'images/excel.png', iconFirst: false, height: '24px', press: function() { window.location = "/workbook" }});vartoolbar = newToolbar({

  • 8/10/2019 Node.pdf

    9/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 9

    With that, our client application is in place.

    Server application

    Node.js includes core library functions to create an HTTP server and client. You have probably

    seen the famous 6 lines of codeto create a Hello world http server in Node.js. The core

    library is intentionally kept light-weight and (relatively) low-level. But is very easy to extend the

    base capabilities of Node by including modules in your code. The Node.js community has

    built a wide range of modulesthat handle common tasks like XML parsing, static file serving,

    request routing etc.

    39404142434445464748

    4950515253545556575859606162

    6364656667686970717273747576

    77787980818283848586

    items: [button]});// Create a master table with sales ordersvarsalesOrders = newDataTable({ title: "Sales Orders", width: "600px", visibleRowCount: 20, toolbar: toolbar, selectionMode: SelectionMode.None,

    editable: false});// define the relevant column optionsvarsalesOrderColumns = [ { header: "Sales Order ID", value: "{SalesOrderID}", width: '100px { header: "Customer Name", value: "{CustomerName}", width: '100%'

    { header: "Net", value: "{NetSum}", width: '100px', hAlign: Right{ header: "Tax", value: "{Tax}", width: '100px', hAlign: Right },

    { header: "Total", value: "{TotalSum}", width: '100px', hAlign: Ri];// create the columnssalesOrderColumns.forEach(function(options) {

    varlabel = newLabel({ text: options.header }), template = newTextView({ text: options.value }), column = newColumn({ label: label, template: template, width: options.width, hAlign: options.hAlign || Begin });

    salesOrders.addColumn(column);});// connect the data table to the SalesOrder servicesalesOrders.setModel(salesOrderModel);

    // An OData request for the SalesOrderCollection// will return the sales orders.// Each sales order should result in a table row.salesOrders.bindRows(salesOrderCollection);// Put table in the DOM.// placeAt will automatically defer if// DOM is not ready yet (like in this demo).salesOrders.placeAt("salesorders");

    https://github.com/joyent/node/wiki/moduleshttp://nodejs.org/
  • 8/10/2019 Node.pdf

    10/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 10

    To keep our server application compact, we will use 2 of these modules:

    express.js: a web application framework on top of Node, to provide request routing

    (connecting incoming requests to JS functions) and serving the static files (the html, js

    and css files for the client application).

    xml2js: to parse the SAP Gateway OData response into a JavaScript object

    To install the modules in your Cloud9 project, you can use NPM (Node Package Manager).

    Just issue the following commands in the command field:

    This will install the modules (and their dependencies) in the node_modules folder of your

    Cloud9 project. Click the refresh button next to Project Files and you can see the results.

    Now we have the required modules installed, we can coding our server.js file which contains

    the server application code. Based on the code of our client application, the server applicationneeds to respond to the following requests:

    / : redirect requests without pathname (i.e. server name only) to index.html in the public

    folder

    /sap/*: forward (proxy) all requests for SAP Gateway content and include authentication

    /workbook: generate an Excel workbook on the fly and deliver as download

    otherwise: serve static files for the client app if contained in the public folder

    npm install expressnpm install xml2js

    http://allthatjs.files.wordpress.com/2012/03/image9.pnghttps://github.com/Leonidas-from-XIV/node-xml2jshttp://expressjs.com/
  • 8/10/2019 Node.pdf

    11/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 1

    So here is server.js, the code to implement the server application

    1234567

    89101112131415161718192021

    2223242526272829303132333435

    36373839404142434445464748

    4950515253545556575859606162

    varhttp = require('http'), express = require('express'), xml2js = require('xml2js'), app = express.createServer(), port = process.env.PORT;// The SalesOrder service requires authentication

    // get the username/password from the SCN page.varusername = 'USERNAME', password = 'PASSWORD';varsapgw = { host: 'gw.esworkplace.sap.com',// set up Basic authentication

    headers: { 'Authorization': 'Basic '+ newBuffer(username + ':'+ password) }}// Action: Proxy an incoming (ie. from the user's browser) request to

    functionproxy(user_request, user_response) {// We're proxying calls,

    // so copy the path from the user request sapgw.path = user_request.url;// Use a client request to call SAP Gateway

    http.get(sapgw, function(sapgw_response) {

    // Include a content type in the response header user_response.header('Content-Type', 'application/atom+xml;type=f

    // In Node, http responses are streams. You can just // pipe the response data from the Gateway to the user.

    sapgw_response.pipe(user_response); });}// Action: Generate an Excel workbook containing SalesOrders on the ffunctionworkbook(req, res) {// We will fetch the SalesOrderCollection from SAP Gateway

    sapgw.path = '/sap/opu/sdata/IWFND/SALESORDER/SalesOrderCollection'// Kick-off by fetching the SalesOrderCollection..http.get(sapgw, function(sapgw_response) {

    varxml = '';

    // Every time Node receives a chunk of data // from SAP Gateway, the 'data' event fires. // We just collect all chunks into a string sapgw_response.on("data", function(chunk) { xml += chunk });

    // The 'end' event fires when the SAP Gateway response is done// We can start processing the xml string...

    sapgw_response.on("end", function() {

    // Node.js doesn't automatically parse the XML (like XmlHttpReq // so we need to do that explicitly.

  • 8/10/2019 Node.pdf

    12/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 12

    63646566676869707172

    7374757677787980818283848586

    87888990919293949596979899100

    101102103104105106107108109110111112113

    114115116117118119120121122123124125126127

    // We will use the xml2js module to parse the XML string // into a JavaScript object // Create a parser to convert the XML to JavaScript object varparser = newxml2js.Parser();

    // The 'end' event fires when the parser is done. // The resulting JS object is passed as parameter. parser.on('end', function (result) { // The result parameter is a complete representation

    // of the parsed XML string.

    // We need to extract the values we need to render the workbo var rows = [],

    // columns is the subset of properties we want to include // in the Excel list columns = ['SalesOrderID', 'CustomerName', 'NetSum', 'Tax', '

    // the value of result['atom:entry'] is an array of objects,// representing 's inthe XML string.

    // Each entry represents a SalesOrder result['atom:entry'].forEach(function(entry) { varrow = {}, // properties points to the parsed properties

    properties = entry['atom:content']['m:properties'];

    columns.forEach(function(property) { // get the value for the property row[property] = properties['d:'+ property]['#'] ||

    properties['d:'+ property]; });

    // add it to the rowsrows.push(row)

    })

    // We're done processing the response and have extracted all// create the workbook.

    // First, include the proper HTTP headers res.header('content-disposition', 'attachment;filename=SalesO res.header('Content-Type', 'application/vnd.ms-excel');

    // Next, render the contents of Excel workbook as // Excel 2003 XML format, using the Workbook.ejs template res.render('Workbook.ejs', { layout: false, rows: rows });

    });

    // Set the parser in motion with the xml data received // from SAP Gateway. The parser will turn the XML string into // a JS object. When done, the 'end' event will fire // and the 'end' event handler defined above will extract the v // and render the Workbook. parser.parseString(xml); });});

    };// Action: perform a redirect to the home page (index.html)function home(req, res) { res.redirect('/index.html')

  • 8/10/2019 Node.pdf

    13/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 13

    You can find the username/password for the SAP Gateway demo environment on this SCN

    page.

    The server application uses an ejs view template to generate the Excel workbook content.

    Express expects these views by default in the views directory. An ejs template is a text file

    interspersed with JavaScript (very similar to classic asp or jsp pages). The view renderer uses

    the template and provided parameter to output a text string, in our case the Excel content.

    Heres the relevant part of the view template (rows are passed as a parameter):

    128129130131132133134135136137

    138139140141142143144145146147148

    }// Now we will set up the routing for the server...// Look if the request is for a static file in the public directory// this is where the client side html, css, js and SAPUI5 resources aapp.use(express.static(__dirname + '/public'));// If you just call the server (root), redirect to homepageapp.get('/', home);

    // Requests starting '/sap/' are proxied to the SAP Gatewayapp.get('/sap/*', proxy);// Route for workbook actionapp.get('/workbook', workbook);// Routes are set up,// Now start the app server...app.listen(port);console.log('Server started on port ' + port);

    1

    23456789101112131415161718192021222324252627

  • 8/10/2019 Node.pdf

    14/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 14

    Now, lets run the application in debugging mode on Cloud9. The Output tab will show the

    output from the application initialization and any console.log statements you include in the

    code. It also provides the url where you can access the running application.

    Click on the server url and our application opens up:

    http://allthatjs.files.wordpress.com/2012/03/image10.png
  • 8/10/2019 Node.pdf

    15/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 15

    Click on the Download as Excel button and Excel workbook with the Sales Orders will open:

    http://allthatjs.files.wordpress.com/2012/03/snaghtmlb193d38.png
  • 8/10/2019 Node.pdf

    16/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 16

    OK, we now have a working application in Cloud9! Theres a lot more to explore in the IDE.

    For example, try the debugging options: you can set breakpoints, just like in desktop IDEs.

    Code execution on remote server will halt and you can explore variable and parameter values,

    etc. You can also push your changes to the central repository on GitHub.

    Here, we will continue our Quick Tour by deploying the application we just completed to

    Windows Azure.

    Step 3: Deploy to Windows Azure

    Cloud9 makes deployment to Windows Azure very easy. This tutorialshows all the steps in

    detail. You can skip the first steps because we already have a working app on Cloud9. Please

    start at Create a Windows Azure account.

    After the initial set up, you can request deployment to Azure:

    http://www.windowsazure.com/en-us/develop/nodejs/tutorials/deploying-with-cloud9/http://allthatjs.files.wordpress.com/2012/03/snaghtmlb1e58751.png
  • 8/10/2019 Node.pdf

    17/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 17

    Cloud9 will offer to create default configuration files for you. Please accept.

    Deploying can take a few minutes, while the application is packaged, uploaded and deployed

    on Azure:

    Once deployment is active, you can click on it and see the details

    http://allthatjs.files.wordpress.com/2012/03/snaghtmlb3a5c8b.pnghttp://allthatjs.files.wordpress.com/2012/03/image11.png
  • 8/10/2019 Node.pdf

    18/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 18

    The Windows Azure management tool provides full details on the deployment:

    Our application is now available on Windows Azure:

    http://allthatjs.files.wordpress.com/2012/03/image13.pnghttp://allthatjs.files.wordpress.com/2012/03/image12.png
  • 8/10/2019 Node.pdf

    19/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 19

    http://nodesapgw.cloudapp.net

    You can try it! Its live.

    Youll notice that it takes quite some time to load the page. This is mainly caused bydynamic loading of SAPUI5 resource files. Optimizations are certainly possible, but outside

    the scope of this article.

    This concludes our demo project to show how you can front-end SAP Gateway using Node.js

    on Azure.

    Just because you can, doesnt mean you should

    Thats a profound adage, so lets wrap-up with a number of suggestions why you may

    consider front-ending SAP Gateway in the Cloud:

    Provide access to multiple backend systems through a single domain (origin). This way,

    you comply with the Same Origin Policy.

    Integrate SAP data in an Azure based cloud solution (E.g. a hosted .Net, MS-SQL

    solution)

    Offload non-business data http traffic of SAP Gateway to a more cost-effective platform.

    Avoid exposing the SAP Gateway end-point to the public internet

    Low-latency traffic by using caching to prevent repeatedly asking the same data via SAP

    Gateway. E.g. for type-ahead and suggestion/select drop-boxes in HTML5 apps, low-

    latency response are required. This is becoming more important with mobile apps where

    quick selections/suggestion lists are preferred of manual input of texts

    Scale-out on demand

    Protocol conversion: you may want to build client applications using other protocols

    (e.g. WebSockets) to expose business data. E.g. consider real-time auctions.

    Content conversion: for example turning business data into Excel sheet as

    demonstrated in our application

    Identity conversion: a consumer facing web application may allow consumers to login

    http://nodesapgw.cloudapp.net/http://allthatjs.files.wordpress.com/2012/03/snaghtmlfdb040.png
  • 8/10/2019 Node.pdf

    20/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 20

    17 T HOUGHTS ON NODE.JS ON AZURE CALLING SAP GATEWAY

    with their Facebook or Twitter account using OAuth2. The web application server can

    connect to SAP Gateway with a functional account.

    Let me know if you have other suggestions/use cases.

    Thanks for reading!

    Helpful resources

    Set up Git

    Deploying a Windows Azure App from Cloud9

    Getting started with Node.js Web Application: describes a local development approach

    for Node.js apps on Azure using the Windows Azure SDK for Node.js.

    Cloud9 help pages

    Overview of Node modules

    SHARE THIS:

    Twitter 41 Facebook 11

    This entry was posted in Azure, GitHub, JavaScript, Node.js, OData, SAP Gateway,

    SAPUI5and tagged Azure, Cloud9, Node.js, SAP Gateway, SAPUI5by lstak. Bookmark

    the permalink [http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/] .

    Like

    Be the first to like this.

    RELATED

    Building a SAP mobile

    app with Sencha Touch 2

    Getting started with

    SAPUI5

    Using SharePoint CSOM

    in Node.js

    rsol1

    on March 22, 2012 at 11:15 amsaid:

    Hi Luc,

    http://allthatjs.com/2012/04/17/using-sharepoint-csom-in-node-js/http://allthatjs.com/2012/02/23/getting-started-with-sapui5/http://allthatjs.com/2012/02/19/building-a-sap-mobile-app-with-sencha-touch-2/http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/http://allthatjs.com/author/lstak/http://allthatjs.com/tag/sapui5/http://allthatjs.com/tag/sap-gateway/http://allthatjs.com/tag/node-js/http://allthatjs.com/tag/cloud9/http://allthatjs.com/tag/azure/http://allthatjs.com/category/sapui5/http://allthatjs.com/category/sap-gateway/http://allthatjs.com/category/odata/http://allthatjs.com/category/node-js/http://allthatjs.com/category/javascript/http://allthatjs.com/category/github/http://allthatjs.com/category/azure/https://github.com/joyent/node/wiki/moduleshttp://support.cloud9ide.com/homehttp://www.windowsazure.com/en-us/develop/nodejs/http://www.windowsazure.com/en-us/develop/nodejs/tutorials/getting-started/https://www.windowsazure.com/en-us/develop/nodejs/tutorials/deploying-with-cloud9/http://help.github.com/win-set-up-git/http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/?share=facebook&nb=1http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/?share=twitter&nb=1
  • 8/10/2019 Node.pdf

    21/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 2

    Thanks again for another informative, thorough and detailed post.

    Over the last 12 months its seems whenever I look under the hood of a site that I am

    impressed with, lately sites like LinkedIn and Trello, I see Node.js featuring

    prominently in their architecture. Initially I kind of dismissed it, server side JavaScript

    just doesnt sound right. Over time however the more I read about the asynchronous

    I/O model the more sense it makes to me, the fact Node.js exposes a JavaScript API

    is a bonus. Your example shows just how easy it use modules and communicate

    between client and server via JavaScript.

    One of the main things I like about Node.js, a part from it looks like a lot of fun, is the

    way it can be used very effectively to push data to the client via events. As you point

    out you have the option of using a variety of protocols like WebSockets and its not

    just limited to HTTP and web content. In my experience there are a lot of use cases in

    the Enterprise where as part of your application you would want your users to react to

    event driven, anything from system notifications to KPI monitoring. In the ABAP

    WebAS when developing UIs we have a couple of ways we can do push (long polling,

    applets etc.) but I believe it doesnt offer anywhere near the concurrency, performance

    and flexibility Node.js can and neither should it.

    Netweaver Gateway supports functionality for subscription and push flow both for

    changes to an Entity and for Business Objects, these can be represented as either a

    simple small notification or full message payload sent to a nominated mediator or

    middleman, I think combining Netweaver Gateway, Node.js and the Cloud you could

    come up with some pretty cool compelling applications and products.

    Cheers

    JSP

    Kevin Grove

    on March 22, 2012 at 3:57 pmsaid:

    Luc:

    Thanks for the excellent post. The step-by-step process is fantastic. The timing is

    great as we are trying to understand mobile development supporting our SAP

    customer base.

    One small issue: in my IE8 browser (I know but thats the official corporate

    browser) I get this error:

    http://groveconsultants.wordpress.com/
  • 8/10/2019 Node.pdf

    22/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 22

    Pingback: Windows Azure Community News Roundup (Edition #11) - Windows Azure

    - Site Home - MSDN Blogs

    Pingback: Windows Azure Community News Roundup (Edition #11) - Windows Azure

    Blog

    Pingback: De Olho no Azure 24/03/2012 Pensando Azure

    Pingback: Pie in the Sky (March 30, 2012) | MSDN Blogs

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.3;

    chromeframe/17.0.963.83; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR

    3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.3; MS-RTC LM 8; .NET4.0C)

    Timestamp: Thu, 22 Mar 2012 14:38:49 UTC

    Message: Object doesnt support this property or method

    Line: 66

    Char: 1

    Code: 0

    URI: http://nodesapgw.cloudapp.net/app.js

    Again, thanks for the informative post.

    lstak

    on March 22, 2012 at 5:25 pmsaid:

    Thanks Kevin.

    The issue with IE8 was related to the use of forEach. Fixed now!

    Kevin Grove

    on March 22, 2012 at 5:56 pmsaid:

    Indeed that corrected the problem, thanks.

    http://groveconsultants.wordpress.com/http://www.oxida.com/http://nodesapgw.cloudapp.net/app.jshttp://msdnrss.thecoderblogs.com/2012/03/pie-in-the-sky-march-30-2012/http://pensandoazure.wordpress.com/2012/03/24/de-olho-no-azure/http://www.windows-azure.net/windows-azure-community-news-roundup-edition-11/http://blogs.msdn.com/b/windowsazure/archive/2012/03/23/windows-azure-community-news-roundup-edition-11.aspx
  • 8/10/2019 Node.pdf

    23/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 23

    Jason

    on April 9, 2012 at 8:14 amsaid:

    Great blog. Im unable to get it to work though. Your test on Azure seems to result in

    an empty dataset as well. Ive tried logging onto gateway directly and it seems theusername and password provided on the website:

    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/1051f6d9-e87a-2e10-d188-

    e2786c7878b1is no longer working

    Maybe they have changed the password without updating the page Or maybe

    gateway is just down at the moment?!?

    lstak

    on April 18, 2012 at 2:04 pmsaid:

    Hi Jason,

    Indeed, the Gateway demo systems was unavailable for a while. Its working

    again now.

    oneman

    on April 24, 2012 at 10:24 amsaid:

    For all of us stacked behind corporate boundaries(IE), Chrome Frame can help a lot

    Shankar Agarwal (@shankaragrawal)

    on May 22, 2012 at 2:58 pmsaid:

    Hi Luc

    Stumbled upon this great blog.Lucky me.Was trying desperately to get some hands

    http://twitter.com/shankaragrawalhttp://www.oxida.com/http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/1051f6d9-e87a-2e10-d188-e2786c7878b1
  • 8/10/2019 Node.pdf

    24/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    http://allthatjs.com/2012/03/21/node-js-on-azure-calling-sap-gateway/ 24

    on action on SAP Gateway and Mobility.I am trying to do the tutorial and facing some

    basic issues(new to advanced javascript) meanwhile i tried to open your application on

    iphone and android,but was unsuccessfull.Do they work on these devices?

    Cheers on the blog!

    Regards

    lstak

    on May 23, 2012 at 8:25 amsaid:

    Hi Shankar,

    The demo was build using SAPUI5 which doesnt support mobile devices

    (yet). If youre interested in HTML5 mobile UIs for SAP Gateway you should

    consider other mobile UI toolkits, e.g. Sencha Touch or jQuery Mobile. The

    following blog can help you get started with SAP and Sencha Touch:

    http://allthatjs.com/2012/02/19/building-a-sap-mobile-app-with-sencha-touch-2/

    John Moy published a great series of blogs on SCN on using jQuery Mobile

    with SAP.

    gunnleiinarsson

    on June 28, 2012 at 1:52 amsaid:

    Hi Luc.

    Definetely interesting all your blogs.

    I was trying to going through the steps in this blog.

    I was able to clone the repo in Cloud9 but but came across errors related tounprotected private key file when pushing/pulling to GitHub .

    The SSH key is inplace.

    Any tips.

    Regards Gunnlaugur

    lstak

    http://www.oxida.com/http://gravatar.com/gunnleihttp://allthatjs.com/2012/02/19/building-a-sap-mobile-app-with-sencha-touch-2/http://www.oxida.com/
  • 8/10/2019 Node.pdf

    25/25

    15/8/2014 Node.js on Azure calling SAP Gateway | And All That JS

    on June 28, 2012 at 8:54 amsaid:

    Hi Gunnlaugur

    I didnt encounter those errors when I did the project for this article, so I am

    afraid I dont have immediate answer. I suggest to look for help at GitHub

    and/or Cloud9

    gunnlei

    on June 28, 2012 at 10:10 amsaid:

    Well I think the platform had some problems yesterday. But when I

    woke upp this morning it was working.

    lstak

    on June 28, 2012 at 2:54 pmsaid:

    Thanks!

    http://www.oxida.com/