In addition to my last anwer: Are you sure your namespaces are correct?
your xml is in the namespace: Yangzhili
regards, Marco
Am 16.09.2013 11:50, schrieb Marco Westermann:
Hi,
in addition to what you do I alway set the fragement property to true.
Try the follwing:
jaxb.setFragment(true)
regards, Marco
Am 16.09.2013 06:40, schrieb hutao722:
Hi,
I tried to do JAXB partial unmarshalling test, but always get null
values
from xml to java object. The code like this:
JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath("org.apache.camel.example.server.model6");
jaxb.setPartClass("org.apache.camel.example.server.model6.MobilePhone");
from("direct:example")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.append("<Result
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"Yangzhili\">");
sb.append("<MobilePhone>");
sb.append("<QueryResult>success</QueryResult>");
sb.append("<AreaCode>100000</AreaCode>");
sb.append("</MobilePhone>");
sb.append("</Result>");
exchange.getIn().setBody(sb.toString());
}
})
.unmarshal(jaxb)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
MobilePhone sq = exchange.getIn().getBody(MobilePhone.class);
if (sq.getQueryResult() != null)
System.out.println("result is : " + sq.toString());
}
});
The class of MobilePhone:
@XmlRootElement(name="MobilePhone")
@XmlAccessorType(XmlAccessType.FIELD)
public class MobilePhone {
@XmlElement
private String QueryResult;
@XmlElement
private String AreaCode;
}
The values of QueryResult & AreaCode are always null. Why? Do i have
some
wrong?
--
View this message in context:
http://camel.465427.n5.nabble.com/JAXB-partial-unmarshalling-tp5739497.html
Sent from the Camel - Users mailing list archive at Nabble.com.