Deploy a web service

When you have your web service application configured correctly and running on the GWS, you are now ready to package the files required to deploy it as a web service on the Genero Application Server.

For the purposes of this quick start, you can use the configuration files created for the Calculator web service. See Configure a web service.

  1. Update the Calculator.xcf <PATH> element as follows:
    <PATH>$(res.deployment.path)/server</PATH>
    The configuration should now look like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <APPLICATION Parent="ws.default" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:noNamespaceSchemaLocation="http://www.4js.com/ns/gas/4.01/cfextws.xsd">
     <EXECUTION>
       <PATH>$(res.deployment.path)/server</PATH>
       <MODULE>CalculatorServer.42r</MODULE>
     </EXECUTION>
    </APPLICATION>
  2. Create a new directory where you will archive the web service runtime files (for example you can name it "calculator_deploy") and in it create a subdirectory called "server".
  3. Copy the application runtime files to the archive directory as follows:
    1. Copy all the files from $FGLDIR/demo/WebServices/calculator/server to the server subdirectory in your archive directory
    2. Copy the updated Calculator.xcf to the server subdirectory.
  4. Create a MANIFEST file and save it with the name "MANIFEST" (without extension) to the directory that contains the application runtime files.
    <MANIFEST>
      <DESCRIPTION>This archive contains one service</DESCRIPTION>
      <SERVICE xcf="Calculator.xcf" />
    </MANIFEST>
  5. Create a Genero Archive (gar) file to deploy your application with the following steps:
    1. Navigate to your Genero Studio installation directory and set the environment.
      • On Linux®/macOS™, change to your Genero Studio root directory and source the script, for example:
        cd /opt/fourjs/gst
        source envgenero 
      • On Windows®, change to your Genero Studio root directory and run the bat file, for example:
        cd "c:\program files\fourjs\gst"
        envgenero.bat 
    2. Navigate to the archive directory that contains the application runtime files AND the MANIFEST file.
    3. Enter the command: fglgar gar.
      A Genero archive (gar) file is created in your current directory that has the same name as the directory. See the fglgar topic in the Genero Business Development Language User Guide.

Test the deployment on your standalone dispatcher.

  1. Deploy your (gar) file locally on your GAS by typing this command:
    gasadmin gar --deploy-archive calculator_deploy.gar
    A subdirectory is created in your GAS appdata/deployment directory (On Linux/UNIX: $FGLASDIR/appdata/deployment, on Windows: C:\ProgramData\FourJs\gas\gas_version\deployment) identified by the archive name and the date and time deployed. In our example, this would be a directory named calculator_deploy-20240827-130838. All the files contained in the Genero Archive (gar) file are placed in the directory.
  2. To enable your deployed web service on your GAS, perform the following steps:

    To list all deployed archives:

    gasadmin gar --list-archives

    To enable the archive, reference it by its archive name:

    gasadmin gar --enable-archive calculator_deploy
    This enables the web service by copying the configuration file to the appdata/services directory (On Linux/UNIX: $FGLASDIR/appdata/services, on Windows: C:\ProgramData\FourJs\gas\gas_version\services ).

To test the deployed web service, start the Calculator server and run a client application that uses the service by performing the following steps:

  1. If your standalone dispatcher is not running, start it from the command line by typing httpdispatch.
    • On Linux/macOS, change to your Genero Studio GAS directory and type httpdispatch, for example:
      cd /opt/fourjs/gst/gas/bin
      httpdispatch
    • On Windows, change to your Genero Studio GAS directory and type httpdispatch, for example:
      cd "c:\program files\fourjs\gst\gas\bin"
      httpdispatch
  2. To start the Calculator web service, in a browser tab enter the address of the web service application:

    http://localhost:6394/ws/r/Calculator

  3. To interact with the Calculator service and show it is working, open another browser tab and enter the address of the demo applications:

    http://localhost:6394/ua/r/gwc-demo

  4. In the Topic tree, navigate to WebServices >> Calculator >> Client. Double-click on the demo Calculator Soap 1.2.
    The Web Services URL dialog appears.
  5. From the drop down menu select one of the following options:
    • http://localhost:6394/ws/r/demo/Calculator

    • Or select the option (Customize) Click here to add your own URL and provide the URL to your configured web service.
    Click OK when finished

    You should see a calculator screen and be able to interact with it. You have successfully deployed a web service.

The steps to configure and deploy a web service on your own machine shown here, can be adapted for deployment on GAS installation on other hosts.