Not able to get Attachment file in CXF Webservice Response
Issue
- Trying to get the attachment from database which has been stored as
byte array. - Reading the stored byte from database and converting to attachment file and sending back the attachment to the response.
- Approach 1: Using a
SOAP HandlerinCXFWebservices to get Attachment.
WrappedMessageContext wmc = (WrappedMessageContext) messageContext;
Message cxfmsg = wmc.getWrappedMessage();
SOAPMessageContextImpl smci = new SOAPMessageContextImpl(cxfmsg);
message = smci.getMessage();
try
{
if(attachmentList!=null)
{
for(Attachment attachmentIterate:attachmentList)
{
attachment = attachmentIterate;
byte[] byt = attachment.getContent();
attach = message.createAttachmentPart();
attach.setRawContentBytes(byt, 0, byt.length, attachment.getContentType());
attach.setContentId(attachment.getContentId());
logger.info("Content Id" + attachment.getContentId());
message.addAttachmentPart(attach);
}
smci.setMessage(message);
}
}
- Approach 2: Using
CXF Interceptorto get Attachment in thesoapUIresponse attachment part. - None of the above approaches are working. Request to provide the solution.
Environment
- Red Hat JBoss Fuse
- 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
