Child pages
  • Deploying using external tools.
Skip to end of metadata
Go to start of metadata

In 8.2 it is possible to deploy an exported .servoy solution by simply doing an HTTP post to the following URL
of a Servoy application server, where you should replace 'deployserver' and the 8080 port number with the ones of target server 


The HTTP post must have 'multipart/form-data' content type, and it should contains the following parts :

  • 'if' - the actual .servoy file, that needs to contains the import options, generated during the export from Servoy developer;
  • 'solution_password' - optional string, used in case the export was password protected

It is recommended to use preemptive authentication (send the credentials in the header) because in case of a bigger upload file, the client will first start to send the file, before the server sending back the request for credential, and that can cause the started upload to be cancelled - with preemptive authentication it will first authenticate

In case of a successful post, the response stream will be a string with the same output as you would get during import on the Servoy application server

Here is a code example in Java, that also has code for authenticate on the Servoy application server

final StringBuilder responseMessage = new StringBuilder();
File inFile = new File(exportFile);
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);

String auth = username + ":" + password;
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("ISO-8859-1")));
String authHeader = "Basic " + new String(encodedAuth);
httppost.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.addPart("if", new FileBody(inFile));
multipartEntityBuilder.addPart("solution_password", new StringBody("secret", ContentType.MULTIPART_FORM_DATA));

// execute the request
HttpResponse response = httpclient.execute(httppost);

if (response.getStatusLine().getStatusCode() == 200)
	HttpEntity responseEntity = response.getEntity();
	String responseString = EntityUtils.toString(responseEntity);
	String[] responses = responseString.split("\n");

	for (String s : responses)
		responseMessage.append("HTTP ERROR : ").append(response.getStatusLine().getStatusCode()).append(' ').append(response.getStatusLine().getReasonPhrase());

Here is a code example in Servoy (it needs Servoy 8.3 because 'usePreemptiveAuthentication' from http plugin is only supported from that version)

	 var _client = plugins.http.createNewHttpClient()
     var _poster = _client.createPostRequest(url)
     _poster.addFile('if', 'file', exportFile)
	 _poster.addParameter('fis', 'true'); // needed to force 'multipart' request
	 _poster.usePreemptiveAuthentication(true); // this is only available from Servoy 8.3
     var _response = _poster.executeRequest(username, password);

  • No labels