Java Code Examples for org.apache.cxf.staxutils.StaxUtils#toNextElement()

The following examples show how to use org.apache.cxf.staxutils.StaxUtils#toNextElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BareOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteInbound() throws Exception {
    GreetMe greetMe = new GreetMe();
    greetMe.setRequestType("requestType");

    message.setContent(List.class, Arrays.asList(greetMe));
    message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);

    interceptor.handleMessage(message);

    writer.close();

    assertNull(message.getContent(Exception.class));

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = StaxUtils.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMe"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "requestType"),
                 reader.getName());
}
 
Example 2
Source File: BareOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteOutbound() throws Exception {
    GreetMeResponse greetMe = new GreetMeResponse();
    greetMe.setResponseType("responseType");

    message.setContent(List.class, Arrays.asList(greetMe));

    interceptor.handleMessage(message);

    writer.close();

    assertNull(message.getContent(Exception.class));

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    //System.err.println(baos.toString());
    XMLStreamReader xr = StaxUtils.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMeResponse"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "responseType"),
                 reader.getName());
}
 
Example 3
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWrapOut() throws Exception {
    GreetMe greetMe = new GreetMe();
    greetMe.setRequestType("tli");
    params.add(greetMe);
    common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(wrapNs, "XMLPort"), GreetMe.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(wrapNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(wrapNs, "greetMe"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);
    assertEquals(wrapGreetMeQName.getNamespaceURI(), dxr.getNamespaceURI());
    assertEquals(wrapGreetMeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(greetMe.getRequestType(), dxr.getText());
}
 
Example 4
Source File: XMLFaultInInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void handleMessage(Message message) throws Fault {

        XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
        DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);

        try {
            reader.nextTag();
            if (!StaxUtils.toNextElement(reader)) {
                throw new Fault(new org.apache.cxf.common.i18n.Message("ILLEGAL_XMLFAULT_FORMAT", BUNDLE));
            }
            String exMessage = reader.getElementText();
            Fault fault = new XMLFault(exMessage);
            reader.nextTag();
            if (StaxUtils.toNextElement(reader)) {
                // handling detail
                Element detail = StaxUtils.read(new FragmentStreamReader(reader)).getDocumentElement();
                fault.setDetail(detail);
            }
            message.setContent(Exception.class, fault);
        } catch (XMLStreamException xse) {
            throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", BUNDLE));
        }

    }
 
Example 5
Source File: StaxDataBindingInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void handleMessage(Message message) {
    if (isGET(message) && message.getContent(List.class) != null) {
        LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method");
        return;
    }

    DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
    DataReader<XMLStreamReader> dr = getDataReader(message);
    MessageContentsList parameters = new MessageContentsList();

    Exchange exchange = message.getExchange();
    BindingOperationInfo bop = exchange.getBindingOperationInfo();

    //if body is empty and we have BindingOperationInfo, we do not need to match
    //operation anymore, just return
    if (!StaxUtils.toNextElement(xmlReader) && bop != null) {
        // body may be empty for partial response to decoupled request
        return;
    }

    if (bop == null) {
        Endpoint ep = exchange.getEndpoint();
        bop = ep.getBinding().getBindingInfo().getOperations().iterator().next();
    }

    message.getExchange().put(BindingOperationInfo.class, bop);

    if (isRequestor(message)) {
        parameters.put(bop.getOutput().getMessageParts().get(0), dr.read(xmlReader));
    } else {
        parameters.put(bop.getInput().getMessageParts().get(0), dr.read(xmlReader));
    }


    if (!parameters.isEmpty()) {
        message.setContent(List.class, parameters);
    }
}
 
Example 6
Source File: DocLiteralInInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void getPara(DepthXMLStreamReader xmlReader,
                     DataReader<XMLStreamReader> dr,
                     MessageContentsList parameters,
                     Iterator<MessagePartInfo> itr,
                     Message message) {

    boolean hasNext = true;
    while (itr.hasNext()) {
        MessagePartInfo part = itr.next();
        if (hasNext) {
            hasNext = StaxUtils.toNextElement(xmlReader);
        }
        Object obj = null;
        if (hasNext) {
            QName rname = xmlReader.getName();
            while (part != null
                && !rname.equals(part.getConcreteName())) {
                if (part.getXmlSchema() instanceof XmlSchemaElement) {
                    //TODO - should check minOccurs=0 and throw validation exception
                    //thing if the part needs to be here
                    parameters.put(part, null);
                }

                if (itr.hasNext()) {
                    part = itr.next();
                } else {
                    part = null;
                }
            }
            if (part == null) {
                return;
            }
            if (rname.equals(part.getConcreteName())) {
                obj = dr.read(part, xmlReader);
            }
        }
        parameters.put(part, obj);
    }
}
 
Example 7
Source File: RPCOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteInbound() throws Exception {
    RPCOutInterceptor interceptor = new RPCOutInterceptor();
    soapMessage.setContent(XMLStreamWriter.class, XMLOutputFactory.newInstance().createXMLStreamWriter(
            baos));

    interceptor.handleMessage(soapMessage);
    assertNull(soapMessage.getContent(Exception.class));
    soapMessage.getContent(XMLStreamWriter.class).flush();
    baos.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = StaxUtils.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_rpclit", "sendReceiveDataResponse"), reader
            .getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);

    assertEquals(new QName(null, "out"), reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);

    assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "elem1"), reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("elem1", reader.getText());
}
 
Example 8
Source File: RPCOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteOutbound() throws Exception {
    RPCOutInterceptor interceptor = new RPCOutInterceptor();

    soapMessage.setContent(XMLStreamWriter.class, XMLOutputFactory.newInstance().createXMLStreamWriter(
            baos));

    soapMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE);

    interceptor.handleMessage(soapMessage);
    assertNull(soapMessage.getContent(Exception.class));
    soapMessage.getContent(XMLStreamWriter.class).flush();
    baos.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = StaxUtils.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_rpclit", "sendReceiveData"), reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName(null, "in"), reader.getName());

    StaxUtils.toNextText(reader);
    assertEquals("elem1", reader.getText());
}
 
Example 9
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBareOutSingle() throws Exception {

    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add(myComplexStruct);

    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"),
                    MyComplexStructType.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "sendReceiveData"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareMyComplexStructTypeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(myComplexStruct.getElem1(), dxr.getText());
}
 
Example 10
Source File: XMLStreamDataWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteWithNamespacePrefixMapping() throws Exception {
    JAXBDataBinding db = getTestWriterFactory(GreetMe.class);
    Map<String, String> nspref = new HashMap<>();
    nspref.put("http://apache.org/hello_world_soap_http/types", "x");
    db.setNamespaceMap(nspref);

    // use the output stream instead of XMLStreamWriter to test
    DataWriter<OutputStream> dw = db.createWriter(OutputStream.class);
    assertNotNull(dw);

    GreetMe val = new GreetMe();
    val.setRequestType("Hello");
    dw.write(val, baos);

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    QName qname = reader.getName();
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMe"), qname);
    assertEquals("x", qname.getPrefix());

    assertEquals(1, reader.getNamespaceCount());
    assertEquals("http://apache.org/hello_world_soap_http/types", reader.getNamespaceURI(0));
    assertEquals("x", reader.getNamespacePrefix(0));

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    qname = reader.getName();
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "requestType"), qname);
    assertEquals("x", qname.getPrefix());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("Hello", reader.getText());
}
 
Example 11
Source File: XMLStreamDataWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteWrapperReturn() throws Exception {
    JAXBDataBinding db = getTestWriterFactory(GreetMeResponse.class);

    DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
    assertNotNull(dw);

    GreetMeResponse retVal = new GreetMeResponse();
    retVal.setResponseType("TESTOUTPUTMESSAGE");

    dw.write(retVal, streamWriter);
    streamWriter.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMeResponse"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "responseType"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("TESTOUTPUTMESSAGE", reader.getText());
}
 
Example 12
Source File: XMLStreamDataWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteWrapper() throws Exception {
    JAXBDataBinding db = getTestWriterFactory(GreetMe.class);

    DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
    assertNotNull(dw);

    GreetMe val = new GreetMe();
    val.setRequestType("Hello");

    dw.write(val, streamWriter);
    streamWriter.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "greetMe"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "requestType"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("Hello", reader.getText());
}
 
Example 13
Source File: XMLStreamDataWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteBare() throws Exception {
    JAXBDataBinding db = getTestWriterFactory(TradePriceData.class);

    DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
    assertNotNull(dw);

    TradePriceData val = new TradePriceData();
    val.setTickerSymbol("This is a symbol");
    val.setTickerPrice(1.0f);

    QName elName = new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout");
    MessagePartInfo part = new MessagePartInfo(elName, null);
    part.setElement(true);
    part.setElementQName(elName);
    dw.write(val, part, streamWriter);
    streamWriter.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_doc_lit_bare/types", "tickerSymbol"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("This is a symbol", reader.getText());
}
 
Example 14
Source File: XMLStreamDataWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteRPCLit2() throws Exception {
    JAXBDataBinding db = getTestWriterFactory(MyComplexStruct.class);

    DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
    assertNotNull(dw);

    MyComplexStruct val = new MyComplexStruct();
    val.setElem1("This is element 1");
    val.setElem2("This is element 2");
    val.setElem3(1);

    QName elName = new QName("http://apache.org/hello_world_rpclit/types",
                             "in");
    MessagePartInfo part = new MessagePartInfo(elName, null);
    part.setElement(true);
    part.setElementQName(elName);

    dw.write(val, part, streamWriter);
    streamWriter.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "in"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "elem1"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("This is element 1", reader.getText());
}
 
Example 15
Source File: XMLStreamDataWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteRPCLit1() throws Exception {
    JAXBDataBinding db = getTestWriterFactory();

    DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
    assertNotNull(dw);

    String val = new String("TESTOUTPUTMESSAGE");
    QName elName = new QName("http://apache.org/hello_world_rpclit/types",
                             "in");
    MessagePartInfo part = new MessagePartInfo(elName, null);
    part.setElement(true);
    part.setElementQName(elName);
    dw.write(val, part, streamWriter);
    streamWriter.flush();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
    StaxUtils.toNextElement(reader);
    assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "in"),
                 reader.getName());

    StaxUtils.nextEvent(reader);
    StaxUtils.toNextText(reader);
    assertEquals("TESTOUTPUTMESSAGE", reader.getText());
}
 
Example 16
Source File: XMLMessageInInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void handleMessage(Message message) throws Fault {
    if (isGET(message)) {
        LOG.fine("XMLMessageInInterceptor skipped in HTTP GET method");
        return;
    }
    Endpoint ep = message.getExchange().getEndpoint();

    XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
    if (xsr == null) {
        return;
    }
    DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);
    if (!StaxUtils.toNextElement(reader)) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT", LOG));
    }

    Exchange ex = message.getExchange();
    QName startQName = reader.getName();
    // handling xml fault message
    if (startQName.getLocalPart().equals(XMLFault.XML_FAULT_ROOT)) {
        message.getInterceptorChain().abort();

        if (ep.getInFaultObserver() != null) {
            ep.getInFaultObserver().onMessage(message);
            return;
        }
    }
    // handling xml normal inbound message
    BindingOperationInfo boi = ex.getBindingOperationInfo();
    boolean isRequestor = isRequestor(message);
    if (boi == null) {
        BindingInfo service = ep.getEndpointInfo().getBinding();
        boi = getBindingOperationInfo(isRequestor, startQName, service, xsr);
        if (boi != null) {
            ex.put(BindingOperationInfo.class, boi);
            ex.setOneWay(boi.getOperationInfo().isOneWay());
        }
    } else {
        BindingMessageInfo bmi = isRequestor ? boi.getOutput() : boi.getInput();

        if (hasRootNode(bmi, startQName)) {
            try {
                xsr.nextTag();
            } catch (XMLStreamException xse) {
                throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", LOG));
            }
        }
    }
}
 
Example 17
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testBareOutMultiWithRoot() throws Exception {

    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add("tli");
    params.add(myComplexStruct);

    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"),
                    MyComplexStructType.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "testMultiParamPart"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareNs, dxr.getNamespaceURI());
    assertEquals("multiParamRootReq", dxr.getLocalName());
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareRequestTypeQName, dxr.getName());
    StaxUtils.nextEvent(dxr);
    if (StaxUtils.toNextText(dxr)) {
        assertEquals("tli", dxr.getText());
    }

    boolean foundRequest = false;
    while (true) {
        StaxUtils.nextEvent(dxr);
        StaxUtils.toNextElement(dxr);
        QName requestType = new QName(dxr.getNamespaceURI(), dxr.getLocalName());
        if (requestType.equals(bareMyComplexStructQName)) {
            foundRequest = true;
            break;
        }
    }
    assertTrue("found request type", foundRequest);
}
 
Example 18
Source File: XMLFaultOutInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testFault() throws Exception {
    FaultDetail detail = new FaultDetail();
    detail.setMajor((short)2);
    detail.setMinor((short)1);
    PingMeFault fault = new PingMeFault("TEST_FAULT", detail);

    XMLFault xmlFault = XMLFault.createFault(new Fault(fault));
    Element el = xmlFault.getOrCreateDetail();
    JAXBContext ctx = JAXBContext.newInstance(FaultDetail.class);
    Marshaller m = ctx.createMarshaller();
    m.marshal(detail, el);

    OutputStream outputStream = new ByteArrayOutputStream();
    xmlMessage.setContent(OutputStream.class, outputStream);
    XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(outputStream);
    xmlMessage.setContent(XMLStreamWriter.class, writer);
    xmlMessage.setContent(Exception.class, xmlFault);

    out.handleMessage(xmlMessage);
    outputStream.flush();

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);

    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals(XMLConstants.NS_XML_FORMAT, dxr.getNamespaceURI());
    assertEquals(XMLFault.XML_FAULT_ROOT, dxr.getLocalName());

    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals(XMLFault.XML_FAULT_STRING, dxr.getLocalName());
    assertEquals(fault.toString(), dxr.getElementText());

    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals(XMLFault.XML_FAULT_DETAIL, dxr.getLocalName());

    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals("faultDetail", dxr.getLocalName());
}