In my Mobile App, i Execute 'MobileService_Login' after user has entered Login_Id and Password. And All other JSDO services are initialised after MobileService_Login is executed.
Sales and Marketing department is requesting to display some dynamic info on Login Page of the App.
I have created the rest service but How do I call this rest service before even calling Login service?
What are my options to call rest service before user is authenticated?
As Bill Wood pointed out, your REST service that provides the marketing information would be set up as a different web application from the one that you already use for the app's main data, with its own JSDO catalog and authentication model. The marketing REST app would need to use the Anonymous authentication model.
As for the steps involved to support two OpenEdge endpoints: You would use the Mobile App Builder to add a second "Session service" to the mobile app, separate from the MobileService_Login/MobileService_Logout group that you already have. You could call it something like MarketingService_Login (and MarketingService_Logout). Execute MarketingService_Login when the app first loads, which would establish a connection only to your marketing service, create a JSDO for the marketing data, and get the marketing data that way. Your should not need to change your existing use of the MobileService_Login service.
Please be aware that we expect to release a new version of the Mobile App Builder very soon (but you would need to check with Product Management for exact timing). The new version of the MAB uses a somewhat different model for working with Session services, and makes it easier to create additional Session services. Currently you would need to create the second group of Session services by copying your existing service or using a plug-in, but our plan is that the process will be much easier in the new release. Please let me know if you would like more details on using a second Session service with the current MAB. Good luck!
-- Wayne Henshaw
That makes sense.
If you can give me little bit more detail about how to create 2nd set of Session service that would be helpful.
How do I create 2nd set of Login/Logout services?
I would appreciate if you can list the steps.
Well, here is a set of steps that should work for you in the current version of the Mobile App Builder. You may want to consider waiting for the new release after you see these, but I would be happy to help you through them if you want to go this route. The basic idea is to copy the existing MobileService and edit the copy to give you the second service. The copy is indirect -- you will need to create a plugin from MobileService and then create a new service from that plugin. (Thanks to Maura Regan for showing me a document she wrote that includes this procedure)
1. Open your project in the Mobile App Builder and select "Export" and then "OpenEdge Plugin"
a. in the dialog that opens up, fill in a Name
b. Uncheck "Export entire project"
c. under "Export entire project" (now unchecked), expand "Services"
d. check MobileService_Login, MobileService_Logout, and MobileService_Settings
(be sure NOT to check any other services that might be there)
e. Click the green Export button at bottom right
2. Should get a dialog box that says the export worked, click OK
3. Now back at the MAB screen for your project
4. Create New | From Plugin
a. Select the plugin that you just created
b. Click "Import selected plug-ins"
5. Dialog box that says "Appery.io plugin(s) were installed successfully." should appear. It asks whether you want to set the Settings now. Might as well check the box for that and click "Apply settings" -- that will create the new services and display the Settings page for them
6. Set the appropriate settings -- the catalogsURIs and serviceURI for the REST service you created for the marketing info, leave the other 2 fields alone. Save.
8 Unfortunately, your new services (and the Settings object) will have the same names as the original services that you made the plugin from, with GUIDs appended, e.g.,
a. you'll see the JS code displayed in the main part of the screen
10. Click on the SessionLogout JS file so you can edit it, too
a. As in the login file, replace $t.SessionLogout (should be on line 9) with $t. + the name of the file you're editing
b. a little farther down (it's line 28 in the file I'm looking at), replace MobileService_Login with the name of your
new MobileService_Login service -- that would be MobileService_Login1369420228594 in the example above, or whatever you may have changed it to (and yes that is correct that even though this is the logout code, you are dealing with the Login service in this particular statement)
11. Be sure to save!
This will give you the second set of Session services. As I outlined earlier, you'd probably want to execute the new Marketing login as soon as the app is activated, by adding it to the Data tab of your main page and executing it in page Load, or something along those lines.
Thank you for perfect instructions. I was able to follow it and have 2 rest services working.
One last question:
How do I share resources / class files between 2 rest services?
Should I just copy my source.cls file to 2nd rest service folder or is there any easier way?
Thanks again for your help with creating 2 rest services. You should make this as a KB article.
That's good to hear!
Regarding the question of sharing resources: Are you asking about deploying source.cls for when your services are running, or sharing it between PDSOE projects when you are doing development?
I am asking about sharing source between PDSOE while developing.
I would like to share a source code object between my 2 projects which I have created for secure and non-secure rest services.
You should be able to put the file into one project and set the PROPATH of your 2nd project so that the 2nd project picks up the file. Is that what you're trying to accomplish?