I found the solution by my self, maybe this will help someone else.
The package-info.class was not generated by the compiling process
(take care of the ANT version) take a look at
http://ant.apache.org/manual/Tasks/javac.html.
After I had tried the solution which is mentioned at
http://stackoverflow.com/questions/4877097/jaxb-2-x-and-ant
everything works fine.
Alex
Am 2011-11-14 10:50, schrieb Alex Declent:
Hi there,
I have developed an web service which receives XML data as attachments
(MTOM),
at the servser side I want to unmarshal the received XML data to an
object.
In my service class I can receive the attachment:
javax.xml.transform.Source.Source source =
body.getRequest.getAttachment().getXmlStream();
debug info for xmlSource (please see attachment), when I call the method
unmarshal(source, AnotherRequestTyp.class) I always get back the
correct object
from type AnotherRequestTypbut each property in it is set to null.
When I test the method unmarshal(source,
AnotherRequestTyp.class)offline with
the same XML data which are send to the server, then it works as I
should.
What me makes wondering is that the systemId and inputStream of the
xmlSource object is null
as you can see on the attached debugging info.
Best regards, Alex
public static <T> T unmarshal(Source source, Class<T> tClass) throws
JAXBException {
JAXBContext jc =
JAXBContext.newInstance(tClass.getPackage().getName());
Unmarshaller u = jc.createUnmarshaller();
JAXBElement<T> doc = (JAXBElement<T>) u.unmarshal(source,
tClass);
return doc.getValue();
}
corresponding jaxb class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RequestTyp", propOrder = {
"product",
"responseFormat",
"xmlStream"
})
public class AbfrageTyp {
@XmlElement(name = "product", required = true)
protected String product;
@XmlElement(name = "responseFormat", required = true)
protected String responseFormat;
@XmlElement(name = "XmlStream", required = true)
@XmlMimeType("text/xml")
protected Source xmlStream;