code: public LaTeXMLServiceResponse parseAsService(String latex) {
          try {
              latex = UriComponentsBuilder.newInstance().queryParam("tex", latex).build().encode(StandardCharsets.UTF_8.toString()).getQuery();
          } catch (UnsupportedEncodingException ignore) {
              LOG.warn("encoding not supported", ignore);
          }
  
          String serviceArguments = config.buildServiceRequest();
          String payload = serviceArguments + "&" + latex;
          RestTemplate restTemplate = new RestTemplate();
  
          try {
              LaTeXMLServiceResponse rep = restTemplate.postForObject(config.getUrl(), payload, LaTeXMLServiceResponse.class);
              LOG.debug(String.format("LaTeXMLServiceResponse:\n"
                              + "statusCode: %s\nstatus: %s\nlog: %s\nresult: %s",
                      rep.getStatusCode(), rep.getStatus(), rep.getLog(), rep.getResult()));
              return rep;
          } catch (HttpClientErrorException e) {
              LOG.error(e.getResponseBodyAsString());
              throw e;
          }
      }
docs: Call a LaTeXML service.
  
  @param latex LaTeX formula
  @return MathML String