XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, "UTF-8",null);
writer.writeStartDocument();
writer.writeStartElement("soap", "Body", Soap12.getInstance().getNamespace());
writer.setPrefix("soap", Soap12.getInstance().getNamespace());
writer.writeNamespace("soap", Soap12.getInstance().getNamespace());
soap12.writeMessage(message, writer, new MessageContext());
writer.writeEndElement();
writer.writeEndDocument();
writer.close();
Document doc = readDocument(out.toString());
//printNode(doc);
addNamespace("s", Soap12.getInstance().getNamespace());
assertValid("//s:SubCode/s:Value[text()='m:NotAvailable']", doc);
addNamespace("t", "urn:test2");
assertValid("//s:Detail/t:bah2[text()='bleh']", doc);
assertValid("//s:Role[text()='http://someuri']", doc);
XMLStreamReader reader = readerForString(out.toString());
InMessage inMsg = new InMessage(reader);
while (reader.hasNext())
{
reader.next();
if (reader.getEventType() == XMLStreamReader.START_ELEMENT
&& reader.getLocalName().equals("Fault"))
{
break;
}
}
soap12.readMessage(inMsg, new MessageContext());
assertNotNull(inMsg.getBody());
assertTrue(inMsg.getBody() instanceof XFireFault);
XFireFault fault2 = (XFireFault) inMsg.getBody();