public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException { try { // MtomCodec sets its own AttachmentMarshaller AttachmentMarshaller am = (sw instanceof MtomStreamWriter) ? ((MtomStreamWriter)sw).getAttachmentMarshaller() : new AttachmentMarshallerImpl(attachmentSet); // Get output stream and use JAXB UTF-8 writer OutputStream os = XMLStreamWriterUtil.getOutputStream(sw); if (os != null) { bridge.marshal(jaxbObject, os, sw.getNamespaceContext(),am); } else { bridge.marshal(jaxbObject,sw,am); } //cleanup() is not needed since JAXB doesn't keep ref to AttachmentMarshaller //am.cleanup(); } catch (JAXBException e) { // bug 6449684, spec 4.3.4 throw new WebServiceException(e); } }
@Override public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException { try { // MtomCodec sets its own AttachmentMarshaller AttachmentMarshaller am = (sw instanceof MtomStreamWriter) ? ((MtomStreamWriter)sw).getAttachmentMarshaller() : new AttachmentMarshallerImpl(attachmentSet); // Get the encoding of the writer String encoding = XMLStreamWriterUtil.getEncoding(sw); // Get output stream and use JAXB UTF-8 writer OutputStream os = bridge.supportOutputStream() ? XMLStreamWriterUtil.getOutputStream(sw) : null; if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.TRUE); m.setAttachmentMarshaller(am); if (os != null) { m.marshal(jaxbObject, os); } else { m.marshal(jaxbObject, sw); } } else { if (os != null && encoding != null && encoding.equalsIgnoreCase(SOAPBindingCodec.UTF8_ENCODING)) { bridge.marshal(jaxbObject, os, sw.getNamespaceContext(), am); } else { bridge.marshal(jaxbObject, sw, am); } } //cleanup() is not needed since JAXB doesn't keep ref to AttachmentMarshaller //am.cleanup(); } catch (JAXBException e) { // bug 6449684, spec 4.3.4 throw new WebServiceException(e); } }
@Override @SuppressWarnings("unchecked") public void writeTo(XMLStreamWriter sw) throws XMLStreamException { try { // MtomCodec sets its own AttachmentMarshaller AttachmentMarshaller am = (sw instanceof MtomStreamWriter) ? ((MtomStreamWriter) sw).getAttachmentMarshaller() : new AttachmentMarshallerImpl(attachmentSet); // Get the encoding of the writer String encoding = XMLStreamWriterUtil.getEncoding(sw); // Get output stream and use JAXB UTF-8 writer OutputStream os = bridge.supportOutputStream() ? XMLStreamWriterUtil.getOutputStream(sw) : null; if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.FALSE); m.setAttachmentMarshaller(am); if (os != null) { m.marshal(jaxbObject, os); } else { m.marshal(jaxbObject, sw); } } else { if (os != null && encoding != null && encoding.equalsIgnoreCase(SOAPBindingCodec.UTF8_ENCODING)) { bridge.marshal(jaxbObject, os, sw.getNamespaceContext(), am); } else { bridge.marshal(jaxbObject, sw, am); } } //cleanup() is not needed since JAXB doesn't keep ref to AttachmentMarshaller } catch (JAXBException e) { // bug 6449684, spec 4.3.4 throw new WebServiceException(e); } }
public final void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException { Marshaller m = context.marshallerPool.take(); m.setAttachmentMarshaller(am); marshal(m,object,output); m.setAttachmentMarshaller(null); context.marshallerPool.recycle(m); }
/** * @since 2.0.2 */ public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException { Marshaller m = context.marshallerPool.take(); m.setAttachmentMarshaller(am); marshal(m,object,output,nsContext); m.setAttachmentMarshaller(null); context.marshallerPool.recycle(m); }
/** * @since 2.0.2 */ public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException { Marshaller m = context.marshallerPool.take(); m.setAttachmentMarshaller(am); marshal(m,object,contentHandler); m.setAttachmentMarshaller(null); context.marshallerPool.recycle(m); }