0
votes

I'm trying to develop a web service to insert data into the database, but testing the service (using soapUI), the object passed as a parameter in the operation is null.

The Endpoint :

@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);
    }
}

The Role entity class:

 @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;
        }
}
1
Maybe you should review a tool called Hyperjaxb3, that enables integration between jpa and jaxb. Hope it helps.Rafael Guillen
@RafaelGuillen thank you. My problem (and what I wish to know more) is how can I pass an object as a parameter in a soap message without using any tools other than jax-ws and jaxbSSouhaieb

1 Answers

0
votes

I found the solution , removing the annotation "@WebParam" before parameter.

@WebMethod(operationName = "addRole")
    @WebResult(name = "int")
    public Integer addRole(Role role){
        return roleService.addRole(role);
}