Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Uploads customization package to WorldServer by posting to the "management_customization" servlet
* Uploads customization package to WorldServer by posting to the "management_customization" servlet.
* @param wsBaseUrl
* @param token
* @param customizationFile
* @throws IOException
private void uploadCustomization(String wsBaseUrl, String token, File customizationFile) throws IOException {
String postActionUrl = wsBaseUrl + "/ws-legacy/management_customization?action=add&token=" + token;"POST URL [" + postActionUrl + "]");
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPostRequest = new HttpPost(postActionUrl);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", customizationFile, ContentType.DEFAULT_BINARY, customizationFile.getName());
builder.addTextBody("comp_type", "9"); // Corresponds to the "Servlet" option in the drop-down in WorldServer
builder.addTextBody("submittedBy", "ok"); // Standard value defined by the Servlet in WorldServer
HttpEntity entity =;
HttpResponse response = httpClient.execute(httpPostRequest);
if (response.getStatusLine().getStatusCode() != 200)
throw new IOException("Error processing customization file [" + customizationFile.getName() + "]");"Finished processing customization entry [" + customizationFile.getName() + "]");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment