code: public void makeServer(ConfigServer configServer, RESTServer restServer)
      throws IOException
    {
  
      DefaultHttpClient client = new DefaultHttpClient();
  
      String host       = configServer.getHost();
      int    configPort = configServer.getPort();
  
  // TODO: SSL
      Authentication authType = configServer.getAuthType();
      if (authType != null) {
        List<String> prefList = new ArrayList<>();
        if (authType == Authentication.BASIC)
          prefList.add(AuthPolicy.BASIC);
        else if (authType == Authentication.DIGEST)
          prefList.add(AuthPolicy.DIGEST);
        else
          throw new IllegalArgumentException(
            "Unknown authentication type: "+authType.name()
          );
        client.getParams().setParameter(
          AuthPNames.PROXY_AUTH_PREF, prefList
        );
  
        String configUser     = configServer.getUser();
        String configPassword = configServer.getPassword();
        client.getCredentialsProvider().setCredentials(
          new AuthScope(host, configPort),
          new UsernamePasswordCredentials(configUser, configPassword)
        );
      }
  
      BasicHttpContext context = new BasicHttpContext();
  
      StringEntity content;
      try {
        content = new StringEntity(restServer.toXMLString());
      } catch (XMLStreamException e) {
        throw new IOException("Could not create payload to bootstrap server.");
      }
      content.setContentType("application/xml");
  
      HttpPost poster = new HttpPost("http://"+host+":"+configPort+"/v1/rest-apis");
      poster.setEntity(content);
  
      HttpResponse response = client.execute(poster, context);
      //poster.releaseConnection();
  
      StatusLine status = response.getStatusLine();
  
      int    statusCode   = status.getStatusCode();
      String statusPhrase = status.getReasonPhrase();
  
      client.getConnectionManager().shutdown();
  
      if (statusCode >= 300) {
        throw new RuntimeException(
          "Failed to create REST server using host=" + host +
          " and port=" + configPort + ": "+
          statusCode+" "+
          statusPhrase+"\n"+
          "Please check the server log for detail"
        );
      }
    }
docs: Programmatic invocation.
  @param configServer	the configuration server for creating the REST server
  @param restServer	the specification of the REST server
  @throws IOException if a communication error occurs