Integratec API Platform
Java

To import the package, first add the opApi.jar file as a library dependency.

Open

// Import the wrapper
import opJavaApi.*;
// Instantiate the object
OPClientConnection api = new OPClientConnection();
// Open a connection
api.open("127.0.0.1", 60000);
// Alternatively, you can instantiate and open in the same call
OPClientConnection api = new OPClientConnection("127.0.0.1", 60000);

SendRequest

// Set input params
String serviceId = "getBrokerIdentity";
String requestJson = "{}";
// Generate a request
String guid = api.sendRequest(serviceId, requestJson);

ReceiveReply

// Get the reply for the specified request ID with a timeout of 100ms
String replyJson = api.receiveReply(guid, 100);

DeleteRequest

// Clean up record of the specified request
api.deleteRequest(guid);

SendRecvDelete

// Create a request, get the reply, and clean up the request
replyJson = api.sendRecvDelete(serviceId, requestJson, 100);

Close

// Close the client connection
api.close();

Status Callback

import com.sun.jna.WString;
import opJavaApi.*;
// Implement an example callback to print the status id and message
class StatusCallback implements OPStatusCallback {
@Override
public void statusCallback(int connection, WString id, WString statusMsg) {
System.out.println(id);
System.out.println(statusMsg);
}
}
public class OPClient {
public static void main(String[] args) throws OPException, java.lang.InterruptedException {
// Instantiate the callback object
StatusCallback callback = new StatusCallback();
// Pass in the status callback pointer argument
OPClientConnection api = new OPClientConnection("127.0.0.1", 60000, callback);
}
}