git clone https://github.com/Evolveum/midpoint.git midpoint
cd midpoint/samples/model-client-sample
Model Web Service Client Sample
OBSOLETE
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:
Use git to check out the source code:
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 |
|
|
|
midPoint user name |
|
|
|
midPoint user password |
|
|
|
OIDs of roles used in the sample |
|
|
constants ROLE_PIRATE_OID, ROLE_CAPTAIN_OID |
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:
-
Getting system configuration object
-
Search for user with username
administrator
-
Searching for role with name
Sailor
-
Creating user
Guybrush Threepwood
with usernameguybrush
-
Changing password of user
guybrush
-
Assing roles
Pirate
andCaptain
to userguybrush
(roles are identified by fixed OID -
Unasssign role
Captain
-
List all roles that have
requestable
flag set to true -
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.