- Persistent storage using YAML file as database (to be easely edited over-the-air by human not machines)
- Dockerized Dev container, using Docker or GitHub Codespaces
- Complex class structure for hotel and reservation instances
- Easy integration between Clients and Servers (in one hand REST and in the other hand SOAP)
- Deep debugging integration using Visual Studio Debbuging tools
By using Microsoft Visual Studio Code and the Remote - Containers extension, you are able to code, test and build from the same and consitent platform. Indeed this Extension will load your project into a docker container. Settings and Dockerfile are available in the
.devcontainer
folder.
To play with this extension, you will need to have docker installed on your computer Name: Remote - Containers
-
Open the project using Visual Studio Code, you will have at the bottom-right corner a notification asking you to open this same project under a Dev container, click on the "Reopen in a container" button.
-
That's it, the dev container will be built, all nodeJS dependancies will be installed, and as soon as the VSCode client became response you will be able to play launch servers and the rest web client !
Develop from anywhere, anytime
Codespaces is currently in invite-only, please save your spot here: https://github.com/features/codespaces/signup
The only thing you need is a web browser
Once you have openned the GitHub repository, you can create a codespaces instance by following this procedure :
- Click on the green buttun "Download Code"
- Then if you don't have any Codespace, use the "+ New Codespace" to launch a new instance
- Wait for the Codespace to instanciate (it should takes only a couples of seconds)
- You're all done, you can now start SOAP & REST servers and the REST Client (web rest client)
Now it's time to start servers and the web rest client.
To do so, whether you are running this project in a container or using Codespaces the procedure is the same !
- Open the "Run tab" on the left of VS Code (or use the
Ctrl
+Shift
+D
shortcut)
- Then, at the top-left corner, select the desired server/client and click the green start button.
- That's it !, you can check if servers and the rest client are running by checking the "Call stack" section (left panel on VS Code), You can use this section to pause, restart or stop any process.
It's now time to play with the WEB Gui, we have designed a special an minimalist rest web client to interract with our REST server.
To do so, whether you are running this project in a container or using Codespaces the procedure is the same !
- Open the "Remote Explorer" tab from the left pannel of VS Code.
- Under the "PORTS" pannel search for the 8080 forwarding rule, and click on the "Open in Browser" icon
- That's it ! You will be automatically redirected to your Codespace instance or directly to localhost (if you're running this project using the Remove Containers plugin)
You now have access to the Web REST Client, forms on this page, filter and booking will be sent using GET/POST methods to the REST server. The REST server will the forward and translate (JSON to XML) your request to the SOAP server.
Using this web client, you can use the first form to search for available hotels depending a selected date, duration and the number of rooms required.
By using the second form, you can make a reservation and book room(s) at the desired hotel
Spoiler, they shouldn't be :)
Spoiler, we can't :)
The REST server is responsible for handling Client request and forwardin them to the SOAP Server.
The REST server must be able to answer to the REST Client. The REST client is making request using GET and POST method on 2 differents endpoints. This is the code responsible for the handling of the routes.
Now that the REST Server has catch the REST Client request, it must translate it to a SOAP request. To do so, we will create a SOAP Client and make the request, Here is a screeshot showing how we handle the request for the filter method using a soap client.
We can see in this screenshot how the REST server is reaching the SOAP server, by giving the SOAP Client the wsdl, it is able to validate and make the request to the desired server using ports and operators.
Here is a sample request made using SOAP UI, a powerful software, SOAP and REST Client to play with SOAP and REST Servers.
-
The request, written in xml
-
The endpoint of the SOAP Server, described in the wsdl
-
The response, also written in XML
After the request is made, the SOAP server send us a response, the response is catch by the callback
method in the rest server.
Here the callback is a function that sent the response to the res
objet (it contain the response).
The SOAP server must expose a WSLD xml file. This file contain services and methods availables. To do so, we have created by hand a wsdl file containing all our methods and port. Here is how we load this file and publish it.
Now that we have exposed our services we must handle them. This is done by passing the myService
object. let's deep dive into this object.
We can seen in this file that services defined in the wsdl file are actually binded here in the myService object.
Keys bind to a function that will handle request for the desired service (filter or book)
Yes, we are storing hotels and reservations both in-merory and in yaml files
Yes, both hotel and reservation are objets well defined using classes.
It's actually really easy, We've found that if a container is running inside codespaces new environment variables are availables. If we detect the
CLOUDENV_ENVIRONMENT_ID
at the startup sequence of servers and the web rest client we update our code accordingly.
We use the same procedure as previously mentionned. Since the REST Client is exposed on the default route (
/
andGET
method) we've create and other route to expose the environment (endpoint
). That way, when the client is loaded in the user navigator, it reach that endpoint and can sent request to the good REST server.