List of usage examples for javax.xml.ws.handler MessageContext OUTBOUND_MESSAGE_ATTACHMENTS
String OUTBOUND_MESSAGE_ATTACHMENTS
To view the source code for javax.xml.ws.handler MessageContext OUTBOUND_MESSAGE_ATTACHMENTS.
Click Source Link
From source file:be.e_contract.dssp.client.DigitalSignatureServiceClient.java
private String addAttachment(String mimetype, byte[] data) { String contentId = UUID.randomUUID().toString(); LOG.debug("adding attachment: " + contentId); DataSource dataSource = new ByteArrayDataSource(data, mimetype); DataHandler dataHandler = new DataHandler(dataSource); BindingProvider bindingProvider = (BindingProvider) this.dssPort; Map<String, Object> requestContext = bindingProvider.getRequestContext(); Map<String, DataHandler> outputMessageAttachments = new HashMap<String, DataHandler>(); requestContext.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, outputMessageAttachments); outputMessageAttachments.put(contentId, dataHandler); return contentId; }
From source file:org.apache.axis2.jaxws.utility.DataSourceFormatter.java
public void writeTo(org.apache.axis2.context.MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { AttachmentsAdapter attachments = (AttachmentsAdapter) messageContext .getProperty(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS); try {// w w w . j a va 2s. c o m if (log.isDebugEnabled()) { log.debug("start writeTo()"); } if (attachments != null && !attachments.isEmpty()) { OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement(); DataSource busObject; try { busObject = (DataSource) ((DataSourceBlock) ((OMSourcedElement) omElement).getDataSource()) .getBusinessObject(true); } catch (XMLStreamException e) { throw AxisFault.makeFault(e); } MIMEOutputUtils.writeDataHandlerWithAttachmentsMessage(new DataHandler(busObject), contentType, outputStream, attachments, format); } else { OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement(); if (omElement != null) { try { if (preserve) { omElement.serialize(outputStream, format); } else { omElement.serializeAndConsume(outputStream, format); } } catch (XMLStreamException e) { throw AxisFault.makeFault(e); } } try { outputStream.flush(); } catch (IOException e) { throw AxisFault.makeFault(e); } } } finally { if (log.isDebugEnabled()) { log.debug("end writeTo()"); } } }
From source file:org.apache.axis2.jaxws.utility.DataSourceFormatter.java
public String getContentType(org.apache.axis2.context.MessageContext messageContext, OMOutputFormat format, String soapAction) {//from ww w. ja v a2 s. com AttachmentsAdapter attachments = (AttachmentsAdapter) messageContext .getProperty(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS); if (attachments != null && !attachments.isEmpty()) { return format.getContentTypeForSwA(contentType); } return contentType; }
From source file:test.unit.be.e_contract.dssp.client.DigitalSignatureServiceTestPort.java
private String addAttachment(String mimetype, String contentId, byte[] data) { LOG.debug("adding attachment: " + contentId); DataSource dataSource = new ByteArrayDataSource(data, mimetype); DataHandler dataHandler = new DataHandler(dataSource); MessageContext messageContext = this.webServiceContext.getMessageContext(); Map<String, DataHandler> outputMessageAttachments = (Map<String, DataHandler>) messageContext .get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS); outputMessageAttachments.put(contentId, dataHandler); messageContext.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, outputMessageAttachments); return contentId; }