Video thumbnail

    Live #065 - How to Enable TOTVS RM Webservice and APIs - (Integrations Part 6)

    This article details the process of enabling Web Services and APIs within TOTVS RM system, facilitating integration with other platforms like Bubble. It covers the crucial steps from configuring server files to exposing these services to the web. The guide emphasizes essential file modifications, service restarts, and the distinction between local and external API access. It also provides insights into handling cloud-based TOTVS RM deployments and offers resources for further learning on modem configurations and DNS setup for public access. The goal is to equip users with the knowledge to establish robust and secure integrations, enabling data flow between TOTVS RM and diverse web applications, thereby expanding the system's utility and automation capabilities.

    Enabling Web Services and APIs in TOTVS RM

    To enable Web Services and APIs in TOTVS RM, you must access the server where TOTVS RM is installed. Navigate to the installation directory, typically C:\Totvs\CorporeRM\RM.Net. Within this folder, locate and modify specific XML configuration files. The primary files to edit are host.exe.config and Host.Service.exe.config.

    You will be able to have a link, a link with two points here, a port that you will enter into the TOTVS RM system, which is this one, which is the web service. How do we generate this link to then go to Bubble, which is our web system that we set up there, and connect with Bubble? How do I generate this link? We will see this in this class.

    Inside these files, you need to adjust or add specific XML tags within the <appSettings> section:

    • DefaultDB Tag: This tag specifies the alias of the database that the Web Service or API will point to. Ensure the value (e.g., CorporeRM_NoGap) exactly matches the database alias configured in your TOTVS RM environment. This is crucial for directing the service to the correct instance, such as production or test environments.

    • HTTPPort and APIPort Tags: These tags define the port numbers for the HTTP Web Service and API, respectively. It is recommended to use the same port number for both (e.g., 8061) to simplify configuration and ensure seamless operation. For example, if port 8051 is already in use, you might opt for 8061. These ports are essential for external systems to communicate with TOTVS RM.

    • ServiceHostName Tag: This tag is optional and used for defining a DNS name for the service instead of an IP address. Using a DNS name (e.g., mycompany.com.br) makes it easier for users to remember and access the service compared to a numerical IP. However, this requires purchasing a domain name and configuring it, which is typically handled by IT infrastructure teams.

    Here’s an example of how the configuration looks in host.exe.config for a server environment:

    <appSettings>
        <add key="DefaultDB" value="CorporeRM_NoGap" />
        <add key="HTTPPort" value="8061" />
        <add key="APIPort" value="8061" />
        <!-- <add key="ServiceHostName" value="yourcompany.com" /> -->
    </appSettings>
    

    After making these changes, save the configuration files.

    Reserving the Port

    Once you have configured the ports in the TOTVS RM files, it is crucial to reserve these ports on the server to prevent other applications from using them. This ensures that the TOTVS RM Web Services and APIs have dedicated access to the specified ports, maintaining service stability and avoiding conflicts.

    You can reserve the port using the netsh http add urlacl command in the Command Prompt (CMD) with administrator privileges.

    You will open the command prompt, the famous CMD, and then you put the command prompt that he says here, from this netsh to the network service. This is the command prompt that you should use. Remember that here is the port that you are going to separate. For example, in this server that I am integrating, which I am going to integrate with Bubble, the port I chose is not 8051, it is 8061, because 8051 I am already using for another purpose. So here I have to separate port 8061. The port you use for RM is the port you have to separate here.

    To do this:

    1. Open Command Prompt as an administrator by pressing Windows key + R, typing cmd, and then pressing Ctrl + Shift + Enter.

    2. Execute the following command, replacing YourPort with the actual port number you configured (e.g., 8061):

      netsh http add urlacl url=http://*:/ user="NT AUTHORITY\NETWORK SERVICE"

    This command reserves the specified port for the Network Service account, ensuring TOTVS RM can use it exclusively without interference from other processes.

    Restarting the TOTVS RM Service

    After modifying the configuration files, it is crucial to restart the TOTVS RM service to apply the changes. This process involves stopping the service, deleting a temporary file called _broker, and then restarting the service.

    You have to compile this file. How do you compile it? You go back here to the rm.net screen. You will have to go to the HOST service, to this file, Host Service Manager. Let me wait for it to open here. See, it will open here for you. You will stop the service. It will be started here, the service. You will be able to restart or stop. In this case, you will stop. After you stop, I do this manually, you will come here in the broker. It has this broker file here. See, I tried to zoom in, it doesn't zoom. Let me go again. You just type _broker, you will find the broker file because it is _broker. You will delete this file and you will start the service again.

    Here’s how to do it:

    1. Access the Host Service Manager: In the same RM.Net directory, locate and open Host.Service.Manager.exe.

    2. Stop the service: In the Host Service Manager window, click the "Stop" button. There's often an option to "Delete Broker" directly when stopping, which automates the next step.

    3. Delete the _broker file: If you didn't use the automated "Delete Broker" option, manually navigate back to the RM.Net folder and delete the file named _broker.

    4. Start the service: Return to the Host Service Manager and click the "Start" button. The system will recreate the _broker file with the updated configurations, applying all your changes.

    Exposing Web Services and APIs to the Web

    After configuring the TOTVS RM service and restarting it, the Web Services and APIs will be accessible locally on the server or within the same local network. To enable external systems, like Bubble or other cloud applications, to connect, you must expose these services to the public web (extranet).

    Cloud Environments (e.g., TOTVS Cloud, AWS)

    If your TOTVS RM instance is hosted on TOTVS Cloud, the process is straightforward. TOTVS provides dedicated support for their cloud offerings.

    If your cloud is TOTVS, you need to open a support ticket with the cloud support and ask them to set up the Web service for you. Just open a ticket, and they will reply with the ready link. If it's TOTVS Cloud, it's easier; they already give you this link, exactly this ready link. You won't have any problems; it's already done.

    Simply open a support ticket with TOTVS Cloud support, requesting them to expose the specific IP address and port for your Web Services and API. They will handle the necessary configurations to make your services publicly accessible.

    For external cloud providers like Amazon Web Services (AWS) where you have direct server access, you will need to submit a request to their cloud support team. Provide them with the internal IP address and port of your TOTVS RM server, and instruct them to expose these to the internet. They will configure their firewall rules or network gateways to enable external access.

    On-Premise or Private Server Environments

    If TOTVS RM is installed on a private server within your company's network, you will need to configure your internet modem or router to expose the internal IP address and port to the external network. This process is commonly referred to as port forwarding.

    You will need to open or access the modem link, you know, the modem you buy for your house. If you turn it upside down, it usually has a small website on the bottom, which is the website for that modem. You access the modem to make configurations there, various modem configurations, change passwords, etc. One of the configurations is to expose the link to the web. So, you will access the link of your modem, it can be, I don't know, TP-Link and so on, and there you have the option to pass to LAN, to the web, and there will be the option to pass your internal IP and port to an external IP and port.

    Steps to configure port forwarding:

    1. Access your Modem/Router: Typically, you can access your modem’s configuration page by typing its default gateway IP address (e.g., 192.168.1.1) into a web browser. The credentials are usually found on a sticker on the modem itself.

    2. Locate Port Forwarding Settings: In the modem's interface, look for sections like "Port Forwarding," "Virtual Servers," or "NAT Settings." The exact location and terminology may vary between modem brands (e.g., TP-Link, D-Link).

    3. Configure a Static IP for the Server: Before setting up port forwarding, ensure your TOTVS RM server has a static internal IP address. This prevents the server’s IP from changing and breaking the port forwarding rule. Infrastructure teams usually configure this during server setup.

    4. Create a New Port Forwarding Rule: Enter the following information:

    5. Save and Restart: Save the new rule and, if prompted, restart your modem for the changes to take effect.

    Once configured, you can test access to your Web Service by navigating to http://:/WS/Page/index in a web browser from an external network. If the page loads successfully, your Web Service is publicly accessible.

    Connecting with Bubble

    After successfully exposing your TOTVS RM Web Services and API to the web, you can integrate them with external platforms like Bubble. This integration allows Bubble applications to fetch or send data to TOTVS RM, enabling powerful automation and data synchronization.

    Bubble, for example, is on an XPTO server. I don't even know what server Bubble is on, but if I come here to plugins, what we saw in the last class, API connector, I even created a new API, but I'm going to exclude it here for us to do it from scratch, just like we did in the previous class. Let's go. Add another API. We come here, put the name, integration NoGap, new test. Then you're going to put here HTTP basic authentication. You're going to put the login and password for RM access. Here's the login and password for the access I use. And here you have the calls. Let's go fetch what we learned in the previous class. Let's go. Hold on, let me search for what we saw in the previous class. I deleted that link. Well, let me search here again on Google for a minute. API TOTVS RM. I'm saying API, I'm all fancy, but it's API, folks. That's the Brazilian-Portuguese way of saying API. I'm too fancy today.

    Steps to connect Bubble with TOTVS RM API:

    1. Open your Bubble application and navigate to the "Plugins" section.

    2. Add the API Connector plugin from the plugin marketplace if you haven't already.

    3. Add a new API connection: Click "Add another API" and configure it with the following details:

    4. Define API Calls: Create individual API calls to interact with specific TOTVS RM data endpoints. For example, to fetch a list of branches (filiais):

    5. Initialize the Call: Click "Initialize Call" to test the connection. Bubble will attempt to connect to TOTVS RM and retrieve sample data. If successful, it will display the data structure and allow you to configure data types for each field.

    For more specific data, such as a single branch, you can create calls with parameters:

    • Method: GET
    • URL: filial/[coligada]/[branch] (where coligada and branch are parameters, e.g., coligada=1, branch=1)
    • Data Type: JSON

    This allows your Bubble application to dynamically request filtered data from TOTVS RM based on user input or other application logic.

    Takeaways

    1. Configuration Steps: To enable Web Services and APIs in TOTVS RM, you must edit configuration files like host.exe.config and Host.Service.exe.config in the RM.Net directory. Key tags to modify include DefaultDB (for database alias) and HTTPPort/APIPort (for service ports). Always save changes and restart the service by deleting the _broker file to apply updates.
    2. Port Reservation: After configuring ports, it's essential to reserve them on the server using the netsh http add urlacl command in an elevated Command Prompt. This prevents port conflicts and ensures TOTVS RM services operate stably.
    3. Exposing to the Web: To enable external access, expose your TOTVS RM Web Services to the internet. For TOTVS Cloud, open a support ticket with them. For private servers, configure port forwarding on your modem/router, mapping the internal IP and port to an external one.
    4. Integration with Bubble: Utilize the Bubble API Connector plugin to link your TOTVS RM APIs. Configure authentication (e.g., HTTP Basic Authentication) and define API calls (e.g., GET requests for specific data). Bubble's initialization allows testing and mapping data types for seamless data exchange.
    5. Future Possibilities: The integration opens up possibilities for various applications, such as fetching student boleto information, generating custom PDF reports, and creating advanced dashboards within Bubble, extending TOTVS RM's functionality and enabling automation workflows.

    References

    This article was AI generated. It may contain errors and should be verified with the original source.
    VideoToWordsClarifyTube

    © 2025 ClarifyTube. All rights reserved.