Not able to get Attachment file in CXF Webservice Response

Solution Verified - Updated -

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 Handler in CXF Webservices 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 Interceptor to get Attachment in the soapUI response 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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content