我有一个web服务:
@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此类:
@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;
}
}
当我测试这个操作我碰到下面的错误,我不能谷歌的解决方案。 也许你可以提供帮助。
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