Source:
<code>public void saveAS4Payloads(Messaging messaging, org.apache.axis2.context.MessageContext axis2MsgContext, String dataInFolder) throws AS4Exception { String messageId = messaging.getUserMessage().getMessageInfo().getMessageId(); List<PartInfo> partInfoList = messaging.getUserMessage().getPayloadInfo().getPartInfo(); if(partInfoList != null) { for (PartInfo partInfo : partInfoList) { if(partInfo.getHref().startsWith(AS4Constants.ATTACHMENT_HREF_PREFIX)) { String cid = partInfo.getHref().substring(AS4Constants.ATTACHMENT_HREF_PREFIX.length()); DataHandler dataHandler = axis2MsgContext.getAttachment(cid); File partFile = new File(dataInFolder + File.separator + cid); try { dataHandler.writeTo(new FileOutputStream(partFile)); } catch (IOException e) { <START> log.error(e); <END> throw new AS4Exception("Error writing payload to file : " + cid, AS4ErrorMapper.ErrorCode.EBMS0004, messageId); } } else if (partInfo.getHref().startsWith(AS4Constants.SOAP_BODY_HREF_PREFIX)) { String cid = partInfo.getHref().substring(AS4Constants.SOAP_BODY_HREF_PREFIX.length()); OMElement payloadElement = axis2MsgContext.getEnvelope().getBody().getFirstElement(); if(payloadElement != null) { try { File partFile = new File(dataInFolder + File.separator + cid); FileOutputStream outputStream = new FileOutputStream(partFile); payloadElement.serialize(outputStream); } catch (Exception e) { log.error(e); throw new AS4Exception("Error writing payload to file : " + cid, AS4ErrorMapper.ErrorCode.EBMS0004, messageId); } } else { throw new AS4Exception("Payload not found in the soap body : " + cid, AS4ErrorMapper.ErrorCode.EBMS0001, messageId); } } } } }</code><technical_language>log error message describing whats failing done creating AS4Exception (same message work I think)</technical_language>

Target:
public void saveAS4Payloads(Messaging messaging, org.apache.axis2.context.MessageContext axis2MsgContext, String dataInFolder) throws AS4Exception { String messageId = messaging.getUserMessage().getMessageInfo().getMessageId(); List<PartInfo> partInfoList = messaging.getUserMessage().getPayloadInfo().getPartInfo(); if(partInfoList != null) { for (PartInfo partInfo : partInfoList) { if(partInfo.getHref().startsWith(AS4Constants.ATTACHMENT_HREF_PREFIX)) { String cid = partInfo.getHref().substring(AS4Constants.ATTACHMENT_HREF_PREFIX.length()); DataHandler dataHandler = axis2MsgContext.getAttachment(cid); File partFile = new File(dataInFolder + File.separator + cid); try { dataHandler.writeTo(new FileOutputStream(partFile)); } catch (IOException e) { log.error("Error writing payload to file : " + cid, e); throw new AS4Exception("Error writing payload to file : " + cid, AS4ErrorMapper.ErrorCode.EBMS0004, messageId); } } else if (partInfo.getHref().startsWith(AS4Constants.SOAP_BODY_HREF_PREFIX)) { String cid = partInfo.getHref().substring(AS4Constants.SOAP_BODY_HREF_PREFIX.length()); OMElement payloadElement = axis2MsgContext.getEnvelope().getBody().getFirstElement(); if(payloadElement != null) { try { File partFile = new File(dataInFolder + File.separator + cid); FileOutputStream outputStream = new FileOutputStream(partFile); payloadElement.serialize(outputStream); } catch (Exception e) { log.error("Error writing payload to file : " + cid, e); throw new AS4Exception("Error writing payload to file : " + cid, AS4ErrorMapper.ErrorCode.EBMS0004, messageId); } } else { throw new AS4Exception("Payload not found in the soap body : " + cid, AS4ErrorMapper.ErrorCode.EBMS0001, messageId); } } } } }