In order to run the GMUS on the system, please follow the steps provided in the article here

  • Make sure the GMUS application is created and registered.

  • Make sure the application users are also registered; one might need to create a new user for the Spring Boot application. 


Let's assume GMUS is running on a local IP address: 192.168.0.111 on port number 8070 (i.e.  http://192.168.0.111:8070).

Now, to run the GMUS services from Spring Boot, one needs to connect to the GMUS URL through the RestTemplate as described below:

 

final String uri = "http://192.168.0.111:8070/rest/scenario"; // 1
RestTemplate restTemplate = new RestTemplate(); // 2
HttpEntity<Map> httpEntity = new HttpEntity<>(payload); // 3
ResponseEntity<String> result = restTemplate.exchange(uri, HttpMethod.POST, httpEntity, String.class); //4


  1. Define the URI for the rest service that needs to be connected; here we are running the scenario.

  2. Create the rest template provided by Spring Boot.

  3. Create the request entity with the payload (the JSON data which is required by the URI).

  4. Send the request; GMUS will then return appropriate message.


Below is the complete controller code:


import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;
import java.util.Map;

@Controller
public class ScenarioController {
 
@PostMapping("/scenario/run")
 @ResponseBody
 public ResponseEntity<String> runScenario(@RequestBody Map<String, Object> payload) {

   final String uri = "http://192.168.0.111:8070/rest/scenario";
   RestTemplate restTemplate = new RestTemplate();
   HttpEntity<Map> httpEntity = new HttpEntity<>(payload);
   ResponseEntity<String> result = restTemplate.exchange(uri, HttpMethod.POST, httpEntity, String.class);
   return result;
 }
}



Below is the screenshot of the REST request placed to Spring Boot application: