Today’s #DelphiWeek blog post is about working with the EMS SignUp Endpoint. You will need to configure your EMS server before following the steps in this post. The demo we are going to build will provide an EMS sign-up screen to sign up a new user.
Enterprise Mobility Services (EMS) is a new turnkey solution for today’s interconnected, distributed apps, offering an easy to deploy middleware server that hosts loadable custom API and data access modules. EMS is based on open and standard technologies, including REST HTTP calls and JSON data formats, and provides major SQL database drivers along with a built-in encrypted SQL datastore.
This application consists of the following components:
- TToolbar with parented TLabel for the application title
- TListBox with 3 items (Username/Password/Button)
- TEdit for Username
- TEdit for Password
- TButton for signing up the user
- TEMSProvider
- TBackendAuth
Use the TEMSProvider component to set up the connection to the EMS Server. Modify the following properties to set up the connection properly.
- URLHost. The URL of the EMS Server. Use:
localhost
if the EMS Server is running on the same machine.- IP Address of the remote EMS Server if it is running on a different machine.
- URLPort. The connection port of the EMS Server.
- Default value:
8080
- Default value:
- URLProtocol. The URL protocol identifier for the request to the EMS Server.
- Default value:
http
- Default value:
Place a TToolbar with a TLabel onto your form. Align the toolbar to MostTop, and the label to Contents with a horizontal aligment setting of Center.
I also placed a TImage onto my form and loaded an icon to it. This further helps identify this as a sign-up screen. Put a TListBox onto your form, and align it to Top. Then set top, bottom, left and right margins so that it fits next to your user graphic. Add three items to your TListbox component. Parent an edit control to each of the first two listbox items for user input, and a button to the third one.
Bind each edit control to the respective BackendAuth1 property using the LiveBindings Designer (View->LiveBindings Designer).
Set up the following on-click event for the ‘Sign Up’ button:
Object Pascal code
procedure TEMS_SignUp.SignUpBtnClick(Sender: TObject); begin BackendAuth1.Signup; ShowMessage('Your user account has been created'); end;
C++ code
//--------------------------------------------------------------------------- void __fastcall TForm20::Button1Click(TObject *Sender) { BackendAuth1->Signup(); ShowMessage("Your user account has been created"); } //---------------------------------------------------------------------------
Deploy this application (in my case, I deployed it to Windows) to sign up a user:
The last step is log in to the EMS console server to see a list of all of the users, access analytics etc.
For more documentation on EMS, please click here.
Special Offer!
If you upgrade from Professional Edition between 21 January 2015 and 31 March 2015, you will receive a free Enterprise Mobility Services 10-user Deployment License (a $1,000 USD value).