Sending data from UI5 to ABAP without gateway? - odata

I have been creating a basic OpenUI5 application, and aiming to implement SAP Gateway very soon.
I currently have a screen that populates an array with simple text-fields and a button. My aim is to send this array/table to a backend ABAP function module or class method. Can this be done? The table has the potential to be quite large.

You need to create a write capable oData service that accepts oData post requests from an UI5 application and writes data to a database table. During implementation of this oData service you may call any ABAP backend class methods of objects that you need to instantiate.
The most important point to realize is that the UI5 application is stateless. The application and all classes are instantiated for processing of the single request and die immediately after the request is processed.

I do not see any problem as long as you do not try to send gigabytes or hundreds of megabytes over the network.
Sending the data to a class method will not be possible as the ABAP methods of classes are not RFC enabled. For this purpose you can use only function modules.

Related

UI5 oData Service for two (or more) different backends

At the moment i still only have about 2 months of experience in UI5. i developed a little sample-app, used sap gateway builder to pass my requests to sap backend.
Now my employer asked me to research the possibility to access two different backends (one sap, one nonsap) via odata from the same app. After a little reading and thinking i came to the conclusion that it would be best to access both backends from a single gateway.
Since ive already worked with sap gateway, i wonder if there is a way to access nonsap backends with sap gateway? Are the better options?
Or is my current approach complete wrong and i should think about a whole other way?
It depends on your approach and the non-sap-system:
Is the non-sap-system accesible via Webservices? Then use second data model (e.g. JSON/ODATA) within SAPUI5 by loading data via webservices after initial loadup of your application.
Is the non-sap-system connected to SAP? E.g. via RFC or another technology, then you can read data from the other system during calling your initial Gateway service and simply call your RFC function module in your method.
From my opinion you will not achieve an 'easy' way to read both via one single SAP NetWeaver Gateway.
Not sure why you would want to access a non-SAP oData service via SAP Gateway. On the other hand you may want a router of some sort so that all services are exposed on the same network location and then incoming requests are routed to the appropriate backend for action.
You may also want to "mash-up" the SAP and non-SAP services into some sort of new service. In that case maybe look to some of the API management tools like Apigee to help you achieve that.

Tips and what to avoid using OData in a multitenant DB SaaS environment

Looking at data access for a multitenant SaaS database for a UI5 app I have two choices - JSON or OData. OData has some features of interest. However, I have concluded that I cannot use OData because of security issues.
In particular I am concerned that OData is a form of query language. As a very rough comparison this is like a SQL statement being composed at the client and sent to an ODBC server for processing. In a multitenant DB I will separate data between owners using, say, and org_id. If it were a SQL query I would have to include select data from table where org_id=this_tennant and .... If I can discover another tenants org_id then I can use an OData explorer to modify the query and pass into the OData source.
In a JSON data interface I would call a REST method that would mask how the data is accessed, and I would not need to expose secret details such as the org_id token. Granted the JSON / REST approach involves more work.
Or do I misunderstand OData ?
Another similar question was asked some time ago but some time has passed so I shall ask again.
The approach of OData is to define how RESTful APIs can be build. It adds a lot of concepts and conventions (e.g. entity types and sets, URL conventions, common query parameters, request format, batch support...) to plain REST and therefore provides you a standard for building your API.
However, it does not define where your data is coming from, but in most cases it will be database. Of course it would be possible to expose your database tables via an OData service in a generic way, but I would expect that the provider of the framework clearly describes how to handle and protect different tenants.
A more specific answer would require more information about the framework you will use.

Using BreezeJS for internal and external API

I need some advice on how to proceed with this design please:
I use BreezeJS internally on top of my Entity Framework Web API. So
all my data retrievals and saves are done in the Breeze style.
I now need to expose an API for external consumption which has a subset of
the calls I use internally.
Ideally I would like to consume the same API internally.
I do not want to tell the consumers that they have to
use BreezeJS on their client-side to consume my API (I am using
Swagger on top of it)
So, for now I have a separate set of API calls for the External API which go through different validation code and have a structure like:
Get(item)
Get(items)
List item
Post(item)
etc.
My question is: Am I going down the wrong track? Should I either be using BreezeJS on the ExternalAPI or stop using Breeze internally and consume the External API, OR should I perhaps wrap the ExternalAPI methods around Breeze and restrict the saving of the entity graph to the entity type that is being queried at the time only?

How to store global per request data in a .NET Web API project

I am working on writing a web api for my application that is currently written using ASP.NET Web Forms. I have a module that acquires some data at the beginning of the request and stores it in HttpContext.Current.Items so that it is available to all code later during the page processing.
I am trying to write my web api and it needs to do the same thing. What is the correct way to store "per request" global data to be used during processing for a web api controller (I suspect it would be the same for a regular controller as well).
Also, if there is a way to do so, is there a way to set this data in an IHttpModule that runs prior to the controller being instantiated.
Any help is appreciated!
You can use the HttpRequestMessage.Properties dictionary as per this StackOverflow question.
There are other options like HttpContext or Session, but they can't be used in a self-hosting setup, only in WebHosting mode.

ASP.NET MVC using as a RESTFUL Service and Consuming it easier way

I wanted to know, if say I had a MVC Application with some functionality and I want to provide this as a service to some of my clients. Do they need to go through coding and querying the XHTML data?(as it is represented in XHTML). I mean how do they generate proxy classes and use my methods? One of the ways is creating URI object but it seems there is still quite a bit of coding to be done in accessing that service(http://msdn.microsoft.com/en-us/magazine/dd943053.aspx).
So , how do i consume the service on Client Side and can I provide a XML?...I have just a simple method that gets user ID and returns details in the controller and respective view. I want to provide this as a service to my client and avoid lot of code.
If you are just exposing a bunch of XML from your various MVC controllers, then the only information clients have to go on is whatever you're doing to document your XML payload format and the URI scheme of your application.
If you want clients to be able to generate client proxies so that they can automatically consume your services, then they'll need some kind of meta data, in which case you should consider using WCF to create RESTful services which would allow for metadata generation and client proxy generation as well as just being able to do just "POX" access.
As the previous commenter said, if all you want to do is expose XML data from your MVC controller, there are a variety of ways this can be done - the easiest of which is just to have your View template render XML tags instead of HTML based on data stored in the ViewData dictionary. You can also very easily expose the underlying data as Json by returning a JsonResult instance from your controller method instead of View().

Resources