最近我一直在浏览此错误的stackoverflow,而且我几乎无法找到所有线程上的解决方案去过。这就是为什么我在这里发布这个问题。未找到Java类型,类bookInfoListType和MIME媒体类型application/xml的消息正文编写器
问题是我在回复响应时说错误。这里是我的XSD定义:
<xs:element name="bookInfoList">
<xs:complexType>
<xs:sequence>
<xs:element name="bookInfo" type="bookInfoType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="bookInfo" type="bookInfoType"/>
<xs:complexType name="bookInfoListType">
<xs:sequence>
<xs:element name="bookInfo" type="bookInfoType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="bookInfoType">
<xs:sequence>
<xs:element name="bookId" type="xs:string" minOccurs="1" maxOccurs="1"/>
<!-- ... more elements !-->
</xs:sequence>
</xs:complexType>
其生成以下bookListInfoType
类
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "bookInfoListType", propOrder = {
"bookInfo"
})
public class bookInfoListType {
protected List<bookInfoType> bookInfo;
public List<bookInfoType> getbookInfo() {
if (bookInfo == null) {
bookInfo = new ArrayList<bookInfoType>();
}
return this.bookInfo;
}
}
但是,当我尝试将响应发送回像
return Response.status(HttpStatus.SC_OK).entity(bookInfoListConverter.convert(wsContext, allBooks)).build();
我得到的说错误。
在我ObjectFactory
,我确实看到
public bookInfoListType createbookInfoListType() {
return new bookInfoListType();
}
这里是我的休息方法:
@Path ("v1/storename/")
public class BookResource
{
@GET
@Path ("books/{book_id}/info.xml")
@Produces (MediaType.APPLICATION_XML)
public Response getBookInfoXML() {
//business logic
return Response.status(HttpStatus.SC_OK).entity(bookInfoListConverter.convert(wsContext, allBooks)).build();
}
}
更何况,我已经生成的类另一个JAXB称为bookInfoList
,你可以在XSD见。他们的定义几乎是一样的(这是我怀疑的一件事,这可能是问题,但我遵循相同模式的其余类都工作正常)。
我仍然试图敲打我的脑袋想弄清楚发生了什么事,但我没有想法,任何帮助将不胜感激。
有什么'clasNameListType'做这件事?什么是错误,确切地说,以及堆栈跟踪? – lexicore 2014-10-10 16:28:01
你可以发布被调用来访问你的服务(包括注释)的方法吗? – 2014-10-10 17:10:49
更新了我的问题并提供了所需的详细信息 – 2014-10-10 17:34:40