Java
Add the Java SDK (nl.bimbase.bimworks:sdk, generated from the OpenAPI) or the classic Java client from the private Maven repository, and check that it connects.
For Java developers who add BIM.works to a Maven or Gradle project. There are two Java SDKs, both in the same private repository (SDKs compares them):
- the Java SDK,
nl.bimbase.bimworks:sdk, generated from the OpenAPI document: one method per operation, over HTTPS. Use it for a new integration; its reference is Java SDK. - the classic Java SDK,
nl.bimbase.bimworks:client, the hand-written client of the task API over HTTP and WebSocket; its reference is Classic Java SDK, and Java quick start is a first program.
Before you start#
- A JDK: 17 or newer, for every artifact on this page.
- Maven 3.6 or newer (or Gradle).
- Credentials for the private repository
https://maven.bim.works. Your company portal has them, or ask support@bimbase.nl.
1. Put the credentials in settings.xml#
The repository is private, so Maven needs a <server> entry whose id matches the repository id used below. The file is ~/.m2/settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>BIM.works</id>
<username>[your username]</username>
<password>[your password]</password>
</server>
</servers>
</settings>2. Add the repository and the dependency#
Use the version that matches your BIM.works server (the version pill at the top of this page is the server's); the SDKs and the server are released in lockstep, see Versioning and compatibility. For the Java SDK:
<dependencies>
<dependency>
<groupId>nl.bimbase.bimworks</groupId>
<artifactId>sdk</artifactId>
<version>3.0.0-beta.192</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>BIM.works</id>
<url>https://maven.bim.works/artifactory/BIM.works</url>
</repository>
</repositories>It brings Jackson (jackson-databind, jackson-datatype-jsr310, jackson-databind-nullable) and uses the JDK's own java.net.http client. For the classic SDK the artifact is client:
<dependencies>
<dependency>
<groupId>nl.bimbase.bimworks</groupId>
<artifactId>client</artifactId>
<version>3.0.0-beta.192</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>BIM.works</id>
<url>https://maven.bim.works/artifactory/BIM.works</url>
</repository>
</repositories>With Gradle:
repositories {
maven {
url = uri("https://maven.bim.works/artifactory/BIM.works")
credentials {
username = "[your username]"
password = "[your password]"
}
}
}
dependencies {
implementation("nl.bimbase.bimworks:sdk:3.0.0-beta.192") // the Java SDK
implementation("nl.bimbase.bimworks:client:3.0.0-beta.192") // or the classic SDK
}What comes with the classic SDK#
The direct dependencies of client, all resolved from the same repository:
| Artifact | Used for |
|---|---|
nl.sascom.backplane:client |
The transport: HTTP and WebSocket connections (Jetty client), requests, tasks and streams. |
nl.bimbase.bimworks:common |
Types shared with the server: Qids, units, error codes, the model classes. |
jakarta.xml.bind:jakarta.xml.bind-api |
XML serialisation. |
Everything else is transitive. Two of those matter to you: Jackson (many SDK methods accept or return ObjectNode/ArrayNode) and the SLF4J API. The client logs through SLF4J and ships no binding; add Logback or another binding to see its log output.
3. Or use the shaded classic artifact#
clientshaded bundles the classic client and its dependencies into one jar, for an application whose own Jetty clashes with the client's. It renames the packages of four of the bundled libraries under nl.bimbase.bimworks.: Jetty (org.eclipse.jetty), Eclipse Collections, JavaFastPFOR and brotli4j. The other bundled libraries keep their package names — Jackson, Guava, commons-io, commons-codec, commons-lang3, commons-compress, HttpClient 5, RoaringBitmap, LZ4, Javassist, Bouncy Castle, zstd-jni and jul-to-slf4j among them — so a different version of one of those on your classpath still clashes, and because they are inside the jar, the shaded artifact's POM no longer lists them. Only slf4j-api is left out of the jar and stays a dependency, so one SLF4J interface is shared with your logging binding.
<dependency>
<groupId>nl.bimbase.bimworks</groupId>
<artifactId>clientshaded</artifactId>
<version>3.0.0-beta.192</version>
</dependency>Like client, the shaded artifact runs on Java 17 or newer. The four renamed libraries log under their new names (nl.bimbase.bimworks.org.eclipse.jetty…); the client itself logs under nl.bimbase.bimworks and nl.sascom.backplane, and the other bundled libraries under their own names.
The former clientlegacy artifact (javax.servlet instead of jakarta.servlet) is discontinued since BIM.works 1.3; the shaded artifact serves the same purpose.
Check#
With the Java SDK, run the program below: it logs in with your API token and prints the UUID of your root node. Every example of the Java SDK has this shape (reference/sdk/java#example-shape).
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
// (GetRootNodeUuid takes no request)
// 3. The call
var result = new FsApi(client).getRootNodeUuid();
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}With the classic SDK, compile and run a class that creates a factory and asks the server for its version. This needs no API token: an anonymous login may call GetApplicationVersion.
import nl.bimbase.bimworks.client.BimWorksClient;
import nl.bimbase.bimworks.client.BimWorksClientFactory;
public class Check {
public static void main(String[] args) throws Exception {
try (BimWorksClientFactory factory = new BimWorksClientFactory("https://bim.works");
BimWorksClient client = factory.createAnonymousClient()) {
System.out.println(client.getApplicationVersion());
}
}
}It prints a JSON object with the server's version. BimWorksClientFactory.createAnonymousClient() and BimWorksClient.getApplicationVersion() are described in Classic Java SDK. Next: Log in with an API token.