我正在
没有与路径/用户/添加用户相关联的JSON Web服务操作 方法POST为/
使用Webservice Rest客户端在Liferay中添加新用户时出错。
我创建了AddUserDTO pojo,其中包含以下字段:
private long companyId;
private boolean autoPassword;
private String password1;
private String password2;
private boolean autoScreenName;
private String screenName;
private String emailAddress;
private long facebookId;
private String openId;
private Locale locale;
private String firstName;
private String lastName;
private String middleName;
private int prefixId;
private int suffixId;
private boolean male;
private int birthdayMonth;
private int birthdayDay;
private int birthdayYear;
private String jobTitle;
private Long [] groupIds;
private Long [] organizationIds;
private Long [] roleIds;
private Long [] userGroupIds;
private boolean sendEmail;
并通过http
传递public HttpRequest httpRequest() throws UKePortalException {
StringBuilder sb = new StringBuilder();
sb.append(getENDPOINT());
System.out.println("Endpoint :"+sb);
if (Method.GET.equals(getMETHOD())) {
sb.append(getParams());
return new HttpGet(sb.toString());
} else if (Method.POST.equals(getMETHOD())) {
HttpPost httpPost = new HttpPost(sb.toString());
httpPost.setEntity(getEntities());
System.out.println("httpPost :"+httpPost+" : "+httpPost.toString());
return httpPost;
}
throw new UKePortalException("No METHOD defined");
}
private HttpEntity getEntities() throws UKePortalException {
List<Field> fields = getAllFields(this.getClass());
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.setCharset(Charset.defaultCharset());
for (Field field : fields) {
Object value = getValue(this, field.getName());
String text = String.valueOf(value);
if (value instanceof File) {
multipartEntityBuilder.addBinaryBody(field.getName(), (File) value);
} else if (!(value instanceof String)) {
text = (new Gson()).toJson(value);
multipartEntityBuilder.addTextBody(field.getName(), text, ContentType.APPLICATION_JSON);
} else {
multipartEntityBuilder.addTextBody(field.getName(), text, ContentType.APPLICATION_JSON);
}
}
return multipartEntityBuilder.build();
}
通过调用httpRequest()方法。我的ENDPOINT设置为&#34; / api / jsonws / user / add-user&#34;
我想知道在调用添加用户时是否遗漏了任何内容。对此有任何帮助表示赞赏。