- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
谁能帮我摆脱这个异常。
unexpected element (uri:"http://cpps.xxx.com/splm-service", local:"PartInquiryService"). Expected elements are (none)
这是我使用的代码和xml
File file = new File("PartInquiryService.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(PartInquiryService.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
PartInquiryService partInqService =
(PartInquiryService)jaxbUnmarshaller.unmarshal(file);
这是我正在使用它的 xml ..我将从 MQ 获取这个 xml 作为响应
<PartInquiryService xmlns="http://cpps.xxx.com/splm-service" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<control>
<type>inquiryWithServiceWindow</type>
<correlationId format="hex">A10488237F3B7734A10488237F3B7734A10488237F3B7734</correlationId>
<origin>
<system>CPPS-SPLM</system>
<id>MP2ZCP5</id>
<at timeZone="UTC">
<date format="ISO">2008-12-12</date>
<time format="ISO">20:12:48</time>
</at>
</origin>
<destination>
<system>SPLM_GUI</system>
<id>SPLM_01</id>
</destination>
</control>
<partInquiry>
<customerSystemkey>123456789123456</customerSystemkey>
<countryCode type="IBM">788</countryCode>
<partnumber>0000039M5123</partnumber>
<machType>1722</machType>
<zipcode>1066 VH</zipcode>
</partInquiry>
<inquiryResult>
<errorMessage>Invalid part number XXXXXXXXXXXX received</errorMessage>
<zipcodeUsed>NL 1066</zipcodeUsed>
<timeZone>MSK</timeZone>
<currency>EUR</currency>
<partnumber>
<id>0000039M5123</id>
<subType>REQ</subType>
<description>POWER CORD</description>
<subRank>0</subRank>
<weigth>10</weigth>
<length>12</length>
<width>9</width>
<height>11</height>
<sellingPrice currency="EUR">12.030</sellingPrice>
<rohsInd>C</rohsInd>
</partnumber>
<partnumber>
<id>0000040K8888</id>
<subType>ALT</subType>
<description>POWER CORD</description>
<subRank>0</subRank>
<weigth>10</weigth>
<length>12</length>
<width>9</width>
<height>11</height>
<sellingPrice currency="EUR">12.030</sellingPrice>
<rohsInd>D</rohsInd>
</partnumber>
<partnumber>
<id>0000012J1234</id>
<subType>SUB</subType>
<description>POWER CORD</description>
<subRank>-1</subRank>
<weigth>10</weigth>
<length>12</length>
<width>9</width>
<height>11</height>
<sellingPrice currency="EUR">12.030</sellingPrice>
<rohsInd>N</rohsInd>
</partnumber>
<sourceLocation>
<locId>788-5000</locId>
<description>CENTRAL BUFFER VENLO</description>
<deliveryOption>
<serviceWindow>Sameday 2hr</serviceWindow>
<logisticCost>88.00</logisticCost>
<date format="ISO">2014-08-24</date>
<time format="ISO">10:56:00</time>
</deliveryOption>
<deliveryOption>
<serviceWindow>Next day 16:00</serviceWindow>
<logisticCost>10.00</logisticCost>
<date format="ISO">2014-08-25</date>
<time format="ISO">16:00:00</time>
</deliveryOption>
<partInventory>
<id>0000039M5123</id>
<availableStock>1</availableStock>
</partInventory>
<partInventory>
<id>0000040K8888</id>
<availableStock>5</availableStock>
</partInventory>
</sourceLocation>
<sourceLocation>
<locId>821-9200</locId>
<description>CRS ST PETERSBURG</description>
<deliveryOption>
<serviceWindow>Sameday 2hr</serviceWindow>
<logisticCost>88.00</logisticCost>
<date format="ISO">2014-08-24</date>
<time format="ISO">10:56:00</time>
</deliveryOption>
<deliveryOption>
<serviceWindow>Next day 16:00</serviceWindow>
<logisticCost>10.00</logisticCost>
<date format="ISO">2014-08-25</date>
<time format="ISO">16:00:00</time>
</deliveryOption>
<partInventory>
<id>0000039M5123</id>
<availableStock>1</availableStock>
</partInventory>
<partInventory>
<id>0000040K8888</id>
<availableStock>5</availableStock>
</partInventory>
</sourceLocation>
<sourceLocation>
<locId>821-1102</locId>
<description>LSH MOSCOW DUTY PAID</description>
<deliveryOption>
<serviceWindow>Sameday 2hr</serviceWindow>
<logisticCost>88.00</logisticCost>
<date format="ISO">2014-08-24</date>
<time format="ISO">10:56:00</time>
</deliveryOption>
<deliveryOption>
<serviceWindow>Next day 16:00</serviceWindow>
<logisticCost>10.00</logisticCost>
<date format="ISO">2014-08-25</date>
<time format="ISO">16:00:00</time>
</deliveryOption>
<partInventory>
<id>0000039M5123</id>
<availableStock>1</availableStock>
</partInventory>
<partInventory>
<id>0000040K8888</id>
<availableStock>5</availableStock>
</partInventory>
</sourceLocation>
</inquiryResult>
</PartInquiryService>
这是 PartInquiryService.java
public class PartInquiryService {
private Control control;
private PartInquiry partInqury;
private InquiryResult inquiryResult;
public Control getControl() {
return control;
}
public void setControl(Control control) {
this.control = control;
}
public PartInquiry getPartInqury() {
return partInqury;
}
public void setPartInqury(PartInquiry partInqury) {
this.partInqury = partInqury;
}
public InquiryResult getInquiryResult() {
return inquiryResult;
}
public void setInquiryResult(InquiryResult inquiryResult) {
this.inquiryResult = inquiryResult;
}
}
最佳答案
在你的类上添加 PartInquiryService.java
@XmlRootElement(name = "PartInquiryService" ,namespace="http://cpps.xxx.com/splm-service")
public class PartInquiryService {
在同一个包中放置这个类(package-info.java
)
@javax.xml.bind.annotation.XmlSchema(namespace = "http://cpps.xxx.com/splm-service", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package your.package;
注意:在这种情况下,@XmlRootElement 中的命名空间不是必需的,但我曾经强调过这一信息。
关于java - 坚持使用 JAXB - 解码 XML 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26774085/
在我的 POJO 中,我有这个: @Transient private int qtyMentee; 在我的 DAO 中我有这个查询: public List findQtyMentee(){
如果我正在编写的应用程序终止,我需要将当前位置存储到 iphone 的“磁盘”中。然后,当应用程序再次启动时,我想恢复这些信息。但是,CLLocation 坐标属性是只读的。 如何在程序调用之间保存此
这个问题有点来回,因为我已经了解了一些关于 unix 系统的 g++ 知识(抱歉,如果我把任何人搞砸了)。 对于我目前正在尝试完成的项目,我想获得 twitcurl使用 Xcode 和 OpenFra
我想在表格中显示用户的姓名以及本周发布的照片数量。 示例:用户 1 发布了 10 张照片,用户 2 发布了 20 张照片...... 所以我需要一个计数,但我不知道如何。 图片型号: public
我正在尝试保留具有@OneToMany 和@ManyToOne 关系的实体。 @OneToMany(mappedBy="customer", cascade=CascadeType.ALL, fetc
我有一个表单,我从另一个表中获取字段,例如,第一个字段是硬编码的,第二个字段是从另一个表中获取的,如果其他表有 10 条记录,则向用户显示 10 个新字段。我的问题是如何将这种数据插入表中。 我得到这
我一直在努力控制导入和导出,这样我就可以精简我的 JS 应用程序。我试过合并这些 Mozilla和 this Stack Overflow examples没有任何运气。 It looks like
我的数据库中的一个字段中包含以下文本: [quote:5a7b87febe="mr smith"]This is some text. This is more text on another lin
我正在使用 cling UPnP android 中的框架连接到支持 UPnP 的设备。我成功地创建了一个设备并浏览了网络中的可用设备。但对于三星电视在网络框架内没有任何反应。在这里我添加了 Rend
我正在制作一个问答网站,类似于此网站和 Yahoo answers。我有 3 个表 - smf_members、qa_questions 和 qa_answers。 在此查询中,我想从 qa_ques
阅读后this question - 它还提供了文档链接,我仍然对文档有疑问。 MDN:Date.parse A string representing an RFC2822 or ISO 8601
我有一个父实体客户端。该客户可以访问该网站并创建约会。这意味着约会是在客户反对的其他时间创建的。 我的问题是:如何将子对象添加到已持久化的父对象中?如果调用下面示例中的函数 addData1(),则会
我正在尝试创建气泡,重复几次后我的浏览器卡住了。这是我的代码。有人请帮助....我如何在不提出许多请求的情况下完成它。 看起来我的帖子主要是代码,但我为这个 Stackoverflow 添加了足够的细
我被这个 linq 查询困住了,我需要做的就是优化最后的价格计算,因为我得到了大约 1000 篇文章,而且销量很大,所以它变得很慢...... var result = from article in
我有一列用于对象创建 的时间,一列用于对象更新 的时间。当我创建并保留新对象时,我从 MySQL 收到错误: updated cannot be null. 我没有为它设置任何值,因为我希望 upda
我以前使用 git 没有任何问题,但突然间我无法推送 或克隆 任何东西。当我使用这个命令时,没有任何反应,甚至没有错误,所以我必须按 ctrl + c 或关闭 git 窗口。 我使用这个简单的命令来推
我似乎不知道下一步该做什么。我的目标是使用图像包中的 SubImage 函数从原始图像创建一个包含所有子图像的数组。我能够在 imageSplit() 函数中分割图像并通过 channel 传递给 i
我有一个 STM32L-Discovery 板,它有一个 STM32L152R8 微处理器。我很难让基本的事情发挥作用。 我看过ST给出的例子(电流消耗触摸传感器和温度传感器),我认为它们不太用户友好
这是一个散列,其中mysql列与散列的键相关,值与散列的值相关 {:jobID=>"1", :checkoutArtificateFolder=>"/cmf/new/build/Artifacts/
我有两个实体 @Entity @Table(name="parent") public class Parent { @Id String uuid; @ElementCollection
我是一名优秀的程序员,十分优秀!