-
1. Re: camel-jaxb unmarshalling as byte[] array?
njiang Jun 14, 2011 9:50 PM (in response to jamie3_james.archibald)I can't tell any thing is wrong according to your camel route.
Can you check if there any error log ?
BTW, which version of camel are you using?
Willem
-
2. Re: camel-jaxb unmarshalling as byte[] array?
jamie3_james.archibald Jun 15, 2011 2:45 PM (in response to njiang)I added a few processors in my route for debugging and changed a few things:
// setup JAXB, This is important otherwise the XML will not get unmarshalled properly
//JAXBContext context = JAXBContext.newInstance(MyObject.class);
String pkg = ObjectFactory.class.getPackage().getName();
JaxbDataFormat jaxb = new JaxbDataFormat(pkg);
//jaxb.setContext(context);
jaxb.setPrettyPrint(true);
jaxb.setPartClass(MyObject.class.getName());
jaxb.setPartNamespace(new QName("http://www.mynamespace.com/foo"));
jaxb.setEncoding("UTF-8");
deadLetterChannel("log:$");
// consume messages from simulation
from("activemq:queue:Foo")
.unmarshal(jaxb) // the output of this is my object but no fields are populated
.process(new CustomProcessor()
.to("activemq:topic:Bar");
I was able to get the class MyObject to unmarshal however the content is empty.
For example:
results in an object
MyClass c;
c.getSomeElement(); // this returns null
One of the things I find very annoying and confusing is that JAXB is not verbose at all. I turned on debugging and I get no errors, warnings, or exceptions.
Edited by: jamie3 on Jun 15, 2011 6:44 PM
-
3. Re: camel-jaxb unmarshalling as byte[] array?
jamie3_james.archibald Jun 15, 2011 3:00 PM (in response to jamie3_james.archibald)OK i seem to have found the issue why JAXB is creating an empty object.
I wrote a unit test which sends both XML documents to the unmarshaller, for example:
I did some debugging and it appears that the second case works. Thus the XML header must be included in order for JAXB to successfully unmarshal the string.
The problem with this is I have a 3rd party system generating the XML document and publishing to my Foo queue. Unfortunately this system does not publish the XML header.
Is there a way around this?
-
4. Re: camel-jaxb unmarshalling as byte[] array?
jamie3_james.archibald Jun 16, 2011 6:55 AM (in response to jamie3_james.archibald)Ok the JAXB generated Java object is now being populated. It looked like there was a type in the namespace.