开发者

JAXB "(variable) is not a valid property" on a ResponseWrapper

I have a webservice:

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

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 setBasicG开发者_如何学Pythonroup(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") 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.


I had the same problem when there were MS Web Service and Java client on JBoss. I generated stub classes using wsconsume. And after that I usually deleted package-info.java because I thought that this is redundant class. After that this case reproduced. After some time I tried to include this file (package-info.java) into project. And it solved the problem.

But when I've used Java Web Service (on JBoss) it works perfectly even without package-info class. It's very strange. Just FYI.

Following link was helpful: link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜