日安社区,
我有一个关于java中castor解组的问题。如前所述,我正在使用castor对包含字节数组(byte[])的webservice响应进行解组。请参考以下内容:
public class ViewReportResponse {
private String reportId;
private byte[] report;
//getters and setters here ...我以前使用castor来解组webservice响应,但无可否认的是,以前的响应总是字符串。返回的字节数组有问题,因为我认为castor在解组它时会卡住。
下面提供了我的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.请提供任何帮助,我们将不胜感激。感谢您的好意
发布于 2015-06-12 02:02:41
已解决:
一般的问题不是与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"/> 这篇文章现在已经被有效地解决和关闭了。
https://stackoverflow.com/questions/30759820
复制相似问题