The MATLAB® Production Server™ Java client API allows you to evaluate MATLAB functions deployed on remote servers using native Java data. The Java client API offers two workflows for client-server communication.
One workflow hides the implementation details of request creation and data
serialization when evaluating MATLAB functions deployed on servers. This workflow uses the
MWHttpClient class and provides the following two options
to evaluate a deployed MATLAB function.
Static proxy — You provide an interface that models the MATLAB function signature. This is a type-safe API that enforces passing the proper data types to the function at compile time.
Dynamic proxy — You pass the function name as a parameter to the proxy along with the function arguments. This defers type checking until runtime.
The other workflow uses the MATLAB Production Server RESTful API for MATLAB Function Execution for MATLAB function execution for request creation and protocol buffers (protobuf) for data serialization. Protocol buffers are a language-neutral and platform-neutral method of serializing structured data.
To use protobuf when making a request to the server, set the
Content-Type header to
in the client code. The Java client library provides helper classes to internally create protobuf messages
based on a proto format and returns the corresponding byte array. Use this byte array in the
HTTP request body. The Java client library provides methods and classes to deserialize the protobuf
In an on-premises MATLAB
Production Server installation, the client APIs are located in
is the MATLAB
Production Server installation location. The client APIs are also available at MATLAB Production Server Client Libraries.
Learn how to create a MATLAB Production Server client in Java.
Learn how to call a MATLAB function deployed to MATLAB Production Server from a Java application.
MWHttpClientDefaultConfig class and override its methods
to modify the default configuration.
Invoke MATLAB functions using a function name and argument list.
This example shows an application that calculates a bond price from a simple formula.
How to use logging capability in the Java client for debugging.
When you write Java interfaces to invoke MATLAB code, remember these considerations:
Example that shows how to make asynchronous RESTful requests using protocol buffers in the Java client.
Example that shows how to make synchronous RESTful requests using protocol buffers in the Java client.
Example that shows the support for structs as input for RESTful requests using protocol buffers in the Java client.
MATLAB allows users to write functions that return multiple outputs.
MATLAB supports functions with both variable number of
input arguments (
varargin) and variable number
of output arguments (
Structures (or structs) are MATLAB arrays with elements accessed by textual field designators.
This example shows how to write a client application that sends an array of objects to a deployed machine learning model .
There are many data types that you can work with in MATLAB.
Rules for data conversion from Java to MATLAB types
List of supported and unsupported MATLAB data types.