简体   繁体   English

JAX-WS-肥皂请求为空

[英]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. 我正在尝试开发一个Web服务以将数据插入数据库,但是测试该服务(使用soapUI)时,在操作中作为参数传递的对象为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. 我找到了解决方案,在参数前删除了注释“ @WebParam”。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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