Search in sources :

Example 1 with ByteArrayDataSource

use of org.apache.axiom.om.ds.ByteArrayDataSource in project webservices-axiom by apache.

the class ByteArrayCustomBuilder method create.

@Override
public OMDataSource create(OMElement element) throws OMException {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        element.serializeAndConsume(baos);
        byte[] bytes = baos.toByteArray();
        return new ByteArrayDataSource(bytes, encoding);
    } catch (XMLStreamException e) {
        throw new OMException(e);
    } catch (OMException e) {
        throw e;
    } catch (Throwable t) {
        throw new OMException(t);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayDataSource(org.apache.axiom.om.ds.ByteArrayDataSource) OMException(org.apache.axiom.om.OMException)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 OMException (org.apache.axiom.om.OMException)1 ByteArrayDataSource (org.apache.axiom.om.ds.ByteArrayDataSource)1