我正在尝试开发一个Web服务来将数据插入数据库,但是测试服务(使用soapUI),在操作中作为参数传递的对象为null。
终点:
@WebService(name = "IAuthencationService", targetNamespace = "http://cursus-web-services",
serviceName = "IAuthencationService")
@Service
public class AuthenticationEndpoint {
@Autowired
UserService userService;
@Autowired
RoleService roleService;
@Autowired
UserRoleService userRoleService;
@WebMethod(operationName = "addRole")
@WebResult(name = "int")
public Integer addRole(
@WebParam(name = "role") Role role){
return roleService.addRole(role);
}
}
角色实体类:
@Entity
@Table(name = "role")
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Role", namespace = "http://cursus-web-services", propOrder = {
"roleId", "role" })
public class Role extends BaseEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4582739221593442099L;
@XmlElement(name = "roleId")
private Integer roleId;
@XmlElement(name = "role")
private String role;
@Id
@Column(name = "ROLE_ID", unique = true, nullable = false)
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
@Column(name = "ROLE", nullable = false, length = 25)
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
}
答案 0 :(得分:0)
我找到了解决方案,删除了注释" @ WebParam"在参数之前。
@WebMethod(operationName = "addRole")
@WebResult(name = "int")
public Integer addRole(Role role){
return roleService.addRole(role);
}