// Serialize
MessageContext msgContext = new MessageContext(new AxisServer());
msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
msgContext.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);
SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
SOAPFault fault = new SOAPFault(new AxisFault(FAULTCODE, FAULTSUBCODE,
FAULTREASON, FAULTROLE,
FAULTNODE, null));
msg.addBodyElement(fault);
Writer stringWriter = new StringWriter();
SerializationContext context =
new SerializationContext(stringWriter, msgContext);
context.setDoMultiRefs(false);
msg.output(context);
String msgString = stringWriter.toString();
// Deserialize and check
AxisServer server = new AxisServer();
Message message = new Message(msgString);
message.setMessageContext(new MessageContext(server));
SOAPEnvelope envelope = message.getSOAPEnvelope();
assertNotNull("envelope should not be null", envelope);
SOAPBodyElement respBody = envelope.getFirstBody();
assertTrue("respBody should be a SOAPFaultElement", respBody
instanceof SOAPFault);
AxisFault aFault = ((SOAPFault) respBody).getFault();
assertNotNull("Fault should not be null", aFault);
assertEquals(FAULTCODE, aFault.getFaultCode());
assertEquals(FAULTREASON, aFault.getFaultReason());
assertEquals(FAULTROLE, aFault.getFaultRole());
assertEquals(FAULTNODE, aFault.getFaultNode());
QName q[] = aFault.getFaultSubCodes();
for (int i = 0; i < q.length; i++)
assertEquals(FAULTSUBCODE[i], q[i]);