String faultDetail = "org.apache.axis2.AxisFault: / by zero \n" +
"... 24 more)";
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultFaultEnvelope();
SOAPFault fault = envelope.getBody().getFault();
fault.getCode().setText(faultCode);
fault.getReason().setText(faultReason);
OMElement exception = factory.createOMElement("Exception", null);
exception.setText(faultDetail);
fault.getDetail().addDetailEntry(exception);
envelope.build();
SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM),
envelope.getXMLStreamReader());
SOAPEnvelope env = stAXSOAPModelBuilder.getSOAPEnvelope();
env.getParent().build();
fault = env.getBody().getFault();
assertEquals(faultCode, fault.getCode().getText());
assertEquals(faultReason,fault.getReason().getText());
exception = (OMElement)fault.getDetail().getFirstOMChild();