Is anyone consuming an AIM REST API from "within" the same AIM app?
I tried previously in v7 and tried again in v8.1. The API works in that I can retrieve the JSON response as expected.
BUT the call to the REST service creates a new browser session (cookie) which causes the original app session (cookie) to expire. It requires logging into the app again.
Any suggestions?
Consuming an AIM REST API from with AIM app
-
- Posts: 619
- Joined: Wed Jun 17, 2015 11:16 pm
- Location: Omaha, Nebraska
- Contact:
Consuming an AIM REST API from with AIM app
VocalDay Solutions - Agility - Predictability - Quality
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
Re: Consuming an AIM REST API from with AIM app
What are you trying to do... just Generate some JSON?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
-
- Posts: 619
- Joined: Wed Jun 17, 2015 11:16 pm
- Location: Omaha, Nebraska
- Contact:
Re: Consuming an AIM REST API from within AIM app
The goal is to decouple the UI from the AIM processes and data actions (CRUD) in a very simple, straightforward manner.
VocalDay Solutions - Agility - Predictability - Quality
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
-
- Posts: 1460
- Joined: Tue Jan 24, 2017 5:51 am
- Location: 'Stralya
Re: Consuming an AIM REST API from with AIM app
Would you not be better using the java API for that?
Re: Consuming an AIM REST API from with AIM app
Another java convertPointsWell wrote:Would you not be better using the java API for that?
Bob
Re: Consuming an AIM REST API from with AIM app
John,The goal is to decouple the UI from the AIM processes and data actions (CRUD) in a very simple, straightforward manner.
If this is the goal, is there a reason why you don't have two AwareIM BSVs and have one provide data to the other via REST service(s)?
Tom - V8.8 build 3137 - MySql / PostGres
-
- Posts: 197
- Joined: Fri Jun 17, 2016 7:10 am
- Location: Brisbane Australia
- Contact:
Re: Consuming an AIM REST API from with AIM app
Hi John,
Did you ever find a solution for this? We have a Kendo Autocomplete widget woking nicely with its datasource being an AwareIM REST service but as you point out calling the REST service overwrites the browsers JSESSIONID cookie so the original SESSION expires.
Did you ever find a solution for this? We have a Kendo Autocomplete widget woking nicely with its datasource being an AwareIM REST service but as you point out calling the REST service overwrites the browsers JSESSIONID cookie so the original SESSION expires.
AWS Linux, Windows Server, AIM 8.4 & 8.6
-
- Posts: 619
- Joined: Wed Jun 17, 2015 11:16 pm
- Location: Omaha, Nebraska
- Contact:
Re: Consuming an AIM REST API from with AIM app
Unfortunately I haven't.
Vlad - Is there a way to work around this issue?
Vlad - Is there a way to work around this issue?
VocalDay Solutions - Agility - Predictability - Quality
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
-
- Posts: 197
- Joined: Fri Jun 17, 2016 7:10 am
- Location: Brisbane Australia
- Contact:
Re: Consuming an AIM REST API from with AIM app
If you extend web.xml from to
Session Cookie name is myServerUserNameXYZ instead of the default JSESSIONID, where myServerUserName is the name of the server user.
Could we replace ${user.name} with something thats mapped to the BSV being called? We would than have BSV specific session cookies on the same server and not have timeouts from the same browser (and be able to ajax call AwareIM REST)? Is this possible in web.xml (and not something that will break AwareIM)?
Code: Select all
<session-config>
<session-timeout>30</session-timeout>
</session-config>
Code: Select all
<session-config>
<session-timeout>30</session-timeout>
<cookie-config>
<name>${user.name}XYZ</name>
</cookie-config>
</session-config>
Could we replace ${user.name} with something thats mapped to the BSV being called? We would than have BSV specific session cookies on the same server and not have timeouts from the same browser (and be able to ajax call AwareIM REST)? Is this possible in web.xml (and not something that will break AwareIM)?
AWS Linux, Windows Server, AIM 8.4 & 8.6
-
- Posts: 197
- Joined: Fri Jun 17, 2016 7:10 am
- Location: Brisbane Australia
- Contact:
Re: Consuming an AIM REST API from with AIM app
I think I have found a workable solution for this issue:
Add following before the closing </web-app> tag in Tomcat\conf\web.xml
Note that this enables ALL domains to access server. Should be more restrictive on a public facing server but OK for development and VPN? You need to restart AwareIM (Tomcat) for this to take effect.
Creating Alias Domain
Create an Alias in DNS or edit your local hosts file.
AJAX this Alias Server
Your javascript should call the Alias server name.
- Enable CORS through your AwareIM Tomcat web.xml configuration file
- Create an alias name for your AwareIM server
- AJAX your REST service using this alias name
Add following before the closing </web-app> tag in Tomcat\conf\web.xml
Code: Select all
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
Creating Alias Domain
Create an Alias in DNS or edit your local hosts file.
AJAX this Alias Server
Your javascript should call the Alias server name.
AWS Linux, Windows Server, AIM 8.4 & 8.6
Re: Consuming an AIM REST API from with AIM app
Dave
I think it should be easier than this.
I started another thread on this - without realizing this thread was here.
I think Support can bypass JSESSIONID creation on a REST request.
Its just a line to add in the code.
This would solve this issue.
I think it should be easier than this.
I started another thread on this - without realizing this thread was here.
I think Support can bypass JSESSIONID creation on a REST request.
Its just a line to add in the code.
This would solve this issue.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
-
- Posts: 7525
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Consuming an AIM REST API from with AIM app
Why do you need to call REST API? This is totally unnecessary. (and not supported)
If you want to decouple the UI from the backend just use the Aware IM XML interface that Aware IM UI code itself uses. The code is available in the AwareIM/Tomcat/webapps/AwareIM/aware_kendo directory.
If you are smart enough to decouple the UI from the backend you should be able to figure out how the Aware IM code does it.
And also,
DO NOT MESS WITH JSESSIONID
If you want to decouple the UI from the backend just use the Aware IM XML interface that Aware IM UI code itself uses. The code is available in the AwareIM/Tomcat/webapps/AwareIM/aware_kendo directory.
If you are smart enough to decouple the UI from the backend you should be able to figure out how the Aware IM code does it.
And also,
DO NOT MESS WITH JSESSIONID
Aware IM Support Team
-
- Posts: 619
- Joined: Wed Jun 17, 2015 11:16 pm
- Location: Omaha, Nebraska
- Contact:
Re: Consuming an AIM REST API from with AIM app
For the majority of base web application functionality, AIM generally offers a quick way to get there. However, there are instances where using Init or Render scripts for custom UI functionality is way more work than just building the functionality from scratch.aware_support wrote:Why do you need to call REST API? This is totally unnecessary. (and not supported)
If you want to decouple the UI from the backend just use the Aware IM XML interface that Aware IM UI code itself uses. The code is available in the AwareIM/Tomcat/webapps/AwareIM/aware_kendo directory.
If you are smart enough to decouple the UI from the backend you should be able to figure out how the Aware IM code does it.
And also,
DO NOT MESS WITH JSESSIONID
For those scenarios, it seems that the best you can offer is a suggestion to dig through ten's of thousands of lines of undocumented AIM JS code?
I'm clearly a masochist, because I have done exactly that as there wasn't another alternative. It certainly wasn't fun or efficient. In a fraction of the code and in 1000th of the time, the same thing could have been done with a custom UI living within the AIM UI framework making REST calls to an AIM service.
This reminds me of the banana / gorilla problem ... "You wanted a banana but what you got was a gorilla holding the banana and the entire jungle."
VocalDay Solutions - Agility - Predictability - Quality
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
We specialize in enabling business through the innovative use of technology.
AwareIM app with beautiful UI/UX - https://screencast-o-matic.com/watch/crfUrrVeB3t
Re: Consuming an AIM REST API from with AIM app
My entire need for my approach is because I need Radio Buttons in a grid.
And since AIM doesn’t support that, I needed to think outside the box.
And I have a perfect solution (actually, better than I could do IN Aware if it DID support radio buttons), except for this SessionID issue.
And since AIM doesn’t support that, I needed to think outside the box.
And I have a perfect solution (actually, better than I could do IN Aware if it DID support radio buttons), except for this SessionID issue.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
-
- Posts: 7525
- Joined: Sun Apr 24, 2005 12:36 am
- Contact:
Re: Consuming an AIM REST API from with AIM app
I still don't understand what REST has to do with it. Why on earth radio buttons in grids require REST???
About having to go through thousands lines of code. All you need to understand is how Aware IM UI "actions work". There is the base class AwareApp.ServerCallAction and about a few dozen of descendants that do everything - from reading/writing an attribute to saving inline edits of a grid. Just look at them and use them or create your own descendants. It is not that hard - certainly not harder than calling REST and parsing JSON.
Once again, REST in Aware IM IS NOT SUPPOSED TO BE CALLED FROM THE UI.
About having to go through thousands lines of code. All you need to understand is how Aware IM UI "actions work". There is the base class AwareApp.ServerCallAction and about a few dozen of descendants that do everything - from reading/writing an attribute to saving inline edits of a grid. Just look at them and use them or create your own descendants. It is not that hard - certainly not harder than calling REST and parsing JSON.
Once again, REST in Aware IM IS NOT SUPPOSED TO BE CALLED FROM THE UI.
Aware IM Support Team