public Message createFault(MessageExchange exchange, Fault fault, Session session, JmsContext context) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PhaseInterceptorChain chain = new PhaseInterceptorChain(); chain.add(new AttachmentsOutInterceptor()); chain.add(new StaxOutInterceptor()); chain.add(new BodyOutInterceptor()); org.apache.servicemix.soap.api.Message msg = new MessageImpl(); msg.setContent(Source.class, fault.getContent()); msg.setContent(OutputStream.class, baos); for (String attId : (Set<String>) fault.getAttachmentNames()) { msg. getAttachments().put(attId, fault.getAttachment(attId)); } chain.doIntercept(msg); TextMessage text = session.createTextMessage(baos.toString()); if (msg.get(org.apache.servicemix.soap.api.Message.CONTENT_TYPE) != null) { text.setStringProperty(CONTENT_TYPE_PROPERTY, (String) msg.get(org.apache.servicemix.soap.api.Message.CONTENT_TYPE)); } text.setBooleanProperty(FAULT_JMS_PROPERTY, true); if (isCopyProperties()) { copyPropertiesFromNM(fault, text); } return text; }