JAXB“(变量)不是有效的属性”在ResponseWrapper上 [英] JAXB "(variable) is not a valid property" on a ResponseWrapper

查看:183
本文介绍了JAXB“(变量)不是有效的属性”在ResponseWrapper上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络服务:

@WebService()
public interface WMCService {

    @WebMethod(operationName="getGroupInfoFromUserId")
    @ResponseWrapper(className="wmc.web.service.BasicGroupWrapper")
    @WebResult(name="basicGroup")
    BasicGroup getGroupInfoFromUserId(@WebParam(name = "id") Long id);
}

@WebService(endpointInterface="wmc.web.service.WMCService", serviceName="WMCService")
public class WMCServiceImpl implements WMCService {

    @Override
    public BasicGroup getGroupInfoFromUserId(Long id) {
        UserHelper uh = new UserHelper();
        WMCUser user = uh.getById(id);
        if (user != null) {
            return user.getBasicGroup();
        } else {
            return null;
        }
    }
}

我有ResponseWrapper:

and I have the ResponseWrapper:

@XmlRootElement()
@XmlType(name="Group")
@XmlAccessorType(XmlAccessType.FIELD)
public class BasicGroupWrapper {

    @XmlElement(name="groupName")
    private String groupName;
    @XmlElement(name="groupId")
    private Long groupId;
    @XmlTransient
    private BasicGroup basicGroup;

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    public void setBasicGroup(BasicGroup group) {
        this.groupName = group.getGroupName();
        this.groupId = group.getId();
        this.basicGroup = group;
    }

    public BasicGroup getBasicGroup() {
        return basicGroup;
    }

}

当我测试这个操作时,我得到了以下错误,我不能谷歌解决方案。也许你可以提供帮助。

When I test this operation I get the following error which I can't google a solution to. Maybe you can help.

Caused by: javax.xml.bind.JAXBException: basicGroup is not a valid property on class wmc.web.service.BasicGroupWrapper
            at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:971)
            at com.sun.xml.ws.server.sei.EndpointResponseMessageBuilder$DocLit.<init>(EndpointResponseMessageBuilder.java:203)
        ... 34 more


推荐答案

@WebResult(name =basicGroup)这不是WSDL的一部分,因为它被标记为 XmlTransient

@WebResult(name="basicGroup") this is not part of your WSDL since it's marked as XmlTransient:

@XmlTransient
private BasicGroup basicGroup;

因此,它无法为您的回复挑选出那部分内容。

So it won't be able to pick out that part of for your response.

这篇关于JAXB“(变量)不是有效的属性”在ResponseWrapper上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆