Hello,
Welcome Back,
In the first part we have learnt about the web services and what are the different method we have in HTTP Request.
In this article , we are going to create a solution in Servoy and write few methods that will map to the HTTP requests.
Before we jump into creating solutions and methods, let understand how servoy handles the requests from HTTP...
1) GET --- ws_read()
When we request with HTTP GET, it will trigger this method in servoy and executes the functionality and this method MUST return either Javascript object or a BYTE array.
2) POST --- ws_create(data)
When we request with HTTP POST, it will trigger ws_create() and we can write our functionality to create database records with the data received with the request. In this method return value is optional but it can return a Javascript object or a byte array.
3) DELETE --- ws_delete()
HTTP DELETE request will trigger this method and delete the specified record and MUST return a Boolean value.
4) PUT - ws_update(data)
HTTP PUT request will trigger this method and it can be used to update existing data in our servoy application. This has to return a Boolean value indicating success or failure.
Now lets create our web services.
Create a HEADLESS client. Why headless client? Here we are exposing our methods in public network. To make this available in the network we have to keep this method available all the time. Who can handle this requirment better that headless client which is independent, running all the time (except in case of server shut down.:P). Name it : servoy_web_services
Then create an empty form on that solution. Name it : servoyWebServiceMethods
Open the script editor and here we will be writing the method that will handle the request from HTTP.
For now.. we have a solution and a form that will contain the methods which will be activated as per the HTTP requests. We can also attach the database table on which the form and data are based upon with the form.
Lets wait for the next article, then we will be learning about creating the URL that will trigger the web service methods and how we will be creating our requests...
Till then..
Happy Coding..
Welcome Back,
In the first part we have learnt about the web services and what are the different method we have in HTTP Request.
In this article , we are going to create a solution in Servoy and write few methods that will map to the HTTP requests.
Before we jump into creating solutions and methods, let understand how servoy handles the requests from HTTP...
1) GET --- ws_read()
When we request with HTTP GET, it will trigger this method in servoy and executes the functionality and this method MUST return either Javascript object or a BYTE array.
2) POST --- ws_create(data)
When we request with HTTP POST, it will trigger ws_create() and we can write our functionality to create database records with the data received with the request. In this method return value is optional but it can return a Javascript object or a byte array.
3) DELETE --- ws_delete()
HTTP DELETE request will trigger this method and delete the specified record and MUST return a Boolean value.
4) PUT - ws_update(data)
HTTP PUT request will trigger this method and it can be used to update existing data in our servoy application. This has to return a Boolean value indicating success or failure.
Now lets create our web services.
Create a HEADLESS client. Why headless client? Here we are exposing our methods in public network. To make this available in the network we have to keep this method available all the time. Who can handle this requirment better that headless client which is independent, running all the time (except in case of server shut down.:P). Name it : servoy_web_services
Then create an empty form on that solution. Name it : servoyWebServiceMethods
Open the script editor and here we will be writing the method that will handle the request from HTTP.
For now.. we have a solution and a form that will contain the methods which will be activated as per the HTTP requests. We can also attach the database table on which the form and data are based upon with the form.
Lets wait for the next article, then we will be learning about creating the URL that will trigger the web service methods and how we will be creating our requests...
Till then..
Happy Coding..
No comments:
Post a Comment