Model Web Service Client Sample

Last modified 07 Sep 2022 03:49 +02:00
This functionality is obsolete. It is no longer supported or maintained.

This is a short description how to use model-client-sample which demonstrates the use of Java client based on JAX-WS. This approach is beneficial because it provides good maintainability of the code on the compiler level. I.e. if the midPoint API changes in an incompatible manner (in future midPoint releases) than the client code will break and indicate the exact place that needs to be fixed. This is saving a lot of testing effort. If the midPoint API changes in a compatible manner then the client code should work without any major change.

MidPoint provides a stand-alone project that is using model-client library. The model-client library is part of midPoint especially designed to support such clients. It contains a JAX-WS and JAX-B code generated from midPoint schemas. Therefore projects that use this library do not need to generate the code and they can simply use this library. There is no need to build model-client library, it is available as a binary JAR in Evolveum Maven Repository. Maven can take advantage of that and he only part that needs to be built is the client code itself. The sample project is configured to do just that. Please inspect the pom.xml file in the project for more details.

Using the Sample

Check-out the Source Code

Use one of the following URLs based on your midPoint version:

Version URL


















development snapshot

Use git to check out the source code:

git clone midpoint
cd midpoint/samples/model-client-sample

Adjust the Configuration

The sample is very simple. All the configuration is hardcoded into the source code. But it is quite easy to change. Just edit few source files:

Setting Default File Location

Web service URL



createModelPort method

midPoint user name



createModelPort method

midPoint user password



handle method

OIDs of roles used in the sample

12345678-d34d-b33f-f00d-987987987988(Pirate), 12345678-d34d-b33f-f00d-987987cccccc(Captain)



The scenario that the client sample does in midPoint is hardcoded in the main method of the Main class. You can adjust it or simple comment out some parts. It goes roughly like this:

  1. Getting system configuration object

  2. Search for user with username administrator

  3. Searching for role with name Sailor

  4. Creating user Guybrush Threepwood with username guybrush

  5. Changing password of user guybrush

  6. Assing roles Pirate and Captain to user guybrush (roles are identified by fixed OID

  7. Unasssign role Captain

  8. List all roles that have requestable flag set to true

  9. Delete user guybrush (which also deletes all the accounts that the roles assigned to the user)

Build It

Use Maven mvn command to build the sample:

mvn clean package

The resulting JAR should appear in the target subdirectory.

Run It

While it is theoretically possible to use java -jar command to run the sample this is a bit difficult in practice. The code will need some libraries on the classpath to run, especially the model-client midPoint library. It is much easier to run the sample using Maven. Maven will make sure that the classpath is populated as needed. Using maven this is not a major problem because this just a sample project. The real midPoint client will be most likely integrated into a larger project and executed a any way that is native to that integrated project.

mvn exec:java -Dexec.mainClass="com.evolveum.midpoint.testing.model.client.sample.Main"

Do not forget that initialized and configued midPoint instance must be running before successfully executing the client sample.

Was this page helpful?
Thanks for your feedback