简体   繁体   中英

JAX-WS - Soap request null

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM