You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by marckropholler <m....@finan.nl> on 2012/03/27 12:01:23 UTC
fixed
Dear all,
Found the following two or three solutions:
1. instantiate custom JAXB/CXF classes that parse the object to xml. The
only thing is that you have to wrap the object in a class containing
@XmlRootElement, which ends up in the exception, but since the classes write
to a org.w3c.dom.Element it (looks like) you can get its child element and
use that. Sample code (without removing root element from xml):
public void handleFault(Message message) {
Fault fault = (Fault) message.getContent(Exception.class);
binding = new
org.apache.cxf.jaxb.JAXBDataBinding(FoutberichtTypeHolder.class);
org.apache.cxf.jaxb.io.DataWriterImpl writer = new
org.apache.cxf.jaxb.io.DataWriterImpl(binding);
writer.write(new FoutberichtTypeHolder(foutberichtType), null,
fault.getOrCreateDetail());
2. Hacky: create a document from an xml file and use that:
public void handleFault(Message message) {
Fault fault = (Fault) message.getContent(Exception.class);
InputStream inputStream = new
ClassPathResource("fault-details.xml").getInputStream();
Document document = DOMUtils.createDocumentBuilder().parse(inputStream);
Node node = XPathAPI.selectSingleNode(document, xpath);
node.setTextContent(text);
fault.setDetail(document.getDocumentElement());
3. Don't know if this one works, but it may: create a Fault object as you
want by specifying it in the wsdl, and setting
it using message.setContent(Exception.class, fault).
Best wishes
Marc
--
View this message in context: http://cxf.547215.n5.nabble.com/Throwing-a-custom-SOAP-Fault-tp5595222p5597436.html
Sent from the cxf-user mailing list archive at Nabble.com.