首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java Castor解组字节数组

Java Castor解组字节数组
EN

Stack Overflow用户
提问于 2015-06-10 22:48:00
回答 1查看 633关注 0票数 0

日安社区,

我有一个关于java中castor解组的问题。如前所述,我正在使用castor对包含字节数组(byte[])的webservice响应进行解组。请参考以下内容:

代码语言:javascript
复制
public class ViewReportResponse {

private String reportId;
private byte[] report;

//getters and setters here ...

我以前使用castor来解组webservice响应,但无可否认的是,以前的响应总是字符串。返回的字节数组有问题,因为我认为castor在解组它时会卡住。

下面提供了我的castor映射文件:

代码语言:javascript
复制
<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>

我不确定我错过了什么,但消息已收到,但在解组时失败。

我在下面附上了一个错误的剪辑。

代码语言:javascript
复制
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.

请提供任何帮助,我们将不胜感激。感谢您的好意

EN

回答 1

Stack Overflow用户

发布于 2015-06-12 02:02:41

已解决:

一般的问题不是与byte[]之间的映射。在这种情况下,问题与名称空间的使用有关。

代码语言:javascript
复制
<field name="reportId"> 
<bind-xml name="ns:reportId" xmlns:ns="http://domain.com/schemas/reportingService/generateReport"
    node="element"
    type="string"/> 
代码语言:javascript
复制
<field name="report"> 
<bind-xml name="ns:report" xmlns:ns="http://domain.com/schemas/reportingService/generateReport"
    node="element"
    type="bytes"/> 

这篇文章现在已经被有效地解决和关闭了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30759820

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档