In previous post:
Accessing Liferay Web Service with Liferay Portal Client demonstrated how to setup Liferay Portal Client and access available Liferay web services.
The demonstrated sample is to retrieve Liferay user.
And now is the time to show how to add a new Liferay user through Liferay Portal Client.
1. initiate the user service
UserServiceSoapServiceLocator locator = new UserServiceSoapServiceLocator();
UserServiceSoap service = locator
.getPortal_UserService(new URL(
"http://username:password@localhost:8080/api/secure/axis/Portal_UserService"));
2. add user to Liferay
UserSoap user = service.addUser(
1L, // companyId,
false, // autoPassword,
password, // password,
confirmPassword, // confirmPassword,
false, // autoScreenName,
screenName, // screenName,
emailAddress, // emailAddress,
0L, // facebookId,
"", // openId,
null, // locale,
firstName, // firstName,
null, // middleName,
lastName, // lastName,
0, // prefixId,
0, // suffixId,
true, // male,
1, // birthdayMonth,
1, // birthdayDay,
1999, // birthdayYear,
null, // jobTitle,
groupIds, // groupIds,
organizationIds, // organizationIds,
roleIds, // roleIds,
userGroupIds, // userGroupIds,
false, // sendEmail,
new ServiceContext());
3. initial user status is no status, change the user status to
ACTIVE
user = userService.updateStatus(user.getUserId(), 0);
Done!!