我已经通过 wadl2java maven 插件从 wadl 文件生成了 java 源代码,并希望通过 Springboot jersey 创建 REST 服务。它到达服务但低于 Excetiption :
`Can not construct instance of javax.xml.bind.JAXBElement: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?) at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@198d51da; line: 5, column: 33]
我的服务端点是这样的:
@Path("getdetails/")
public class GetdetailsResource {
@POST
@Consumes({"application/xml", "application/json" })
@Produces({"application/xml", "application/json" })
public Response GETDETAILS(InputParameters parameters) {
'''''
System.out.println(parameters);
....
return null;
}
}
REST 调用在解组创建具有 JAXBElement jaxbElement 的 InputParameters 时引发异常;
不知何故,即使使用此处提到的 ObjectMapper,JaxbElement 也永远不会被实例化
InputParameters 类如下:
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"carray"
})
@XmlRootElement(name = "InputParameters")
public class InputParameters {
public InputParameters() {
// TODO Auto-generated constructor stub
System.out.println();
}
@XmlElementRef(name = "P_CONTRACT_ARRAY", namespace = "http://xmlns.oracle.com/apps/getdetails/", type = JAXBElement.class, required = false)
protected JAXBElement<APPAXX> carray;
public JAXBElement<APPAXX> getcarray() {
return carray;
}
public void setcarray(JAXBElement<APPAXX> value) {
this.carray = value;
}
}