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;

Reply via email to