[英]Java Castor Unmarshal byte array
美好的一天社区,
我有一个关于在Java中解压缩脚轮的问题。 如前所述,我使用Castor解组包含字节数组(byte [])..的Web服务响应,请参阅以下内容:
public class ViewReportResponse {
private String reportId;
private byte[] report;
//getters and setters here ...
之前,我曾使用castor解组网络服务响应,但是,坦白地说,以前的响应始终是字符串。 问题在于字节数组返回,因为我相信脚轮在解组它时会窒息。
我的脚轮映射文件如下:
<class name="com.domain.reporting.client.service.ViewReportResponse">
<map-to xml="viewReportResponse"
xsi:schemaLocation="http://domain.com/schemas/reportingService/generateReport"
ns-uri="http://domain.com/schemas/reportingService/generateReport"
ns-prefix="ns2" />
<field name="reportId">
<bind-xml name="reportId"
node="element"
type="string"/>
</field>
<field name="report">
<bind-xml name="report"
node="element"
type="bytes" />
</field>
我不确定我缺少什么,但是收到了消息,但在取消编组时失败。
我已附上以下错误的片段。
org.springframework.oxm.UnmarshallingFailureException: Castor unmarshalling exception; nested exception is org.exolab.castor.xml.MarshalException: unable to find FieldDescriptor for 'report' in ClassDescriptor of viewReportResponse.
请任何帮助,不胜感激。 非常感谢你
解决了:
通常的问题不是与byte []之间的映射。 在这种情况下,问题与名称空间的使用有关。
<field name="reportId">
<bind-xml name="ns:reportId" xmlns:ns="http://domain.com/schemas/reportingService/generateReport"
node="element"
type="string"/>
<field name="report">
<bind-xml name="ns:report" xmlns:ns="http://domain.com/schemas/reportingService/generateReport"
node="element"
type="bytes"/>
现在,该帖子已被有效解决并关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.