DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14611>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14611 Fault Detail access code inside SOAPFault operates on the detail objects NOT used in serialization. ------- Additional Comments From [EMAIL PROTECTED] 2002-12-16 02:01 ------- This is actually a serious bug because it you cannot implement a SAAJ application using Axis (contrary to its full compliance claim). I attached a simple SAAJ client which reads a SOAP fault message from a file, read the detail and prints a message. The result of a test run is as follows: ==================================================================== D:\jdev\jdk\bin\javaw.exe -ojvm unit.test.DetailTest reply-error.xml java.lang.ClassCastException: org.apache.axis.message.MessageElement javax.xml.soap.Detail org.apache.axis.message.SOAPFault.getDetail() void unit.test.DetailTest.run() void unit.test.DetailTest.main(java.lang.String[]) Exception in thread main Process exited with exit code 1. ================================================= The reason is a bug in getDetal() which simply reads a child node of SoapFault. The Detail object related info is part of the AxisFault private - as Taras points out. I wrote a static helper which may be of use in fixing the bug: The heleper converts AxisFault info into a Detail. Here is the source for the helper: =========================================================================== private static Detail convertToDetail(AxisFault fault) throws SOAPException { Detail detail = new Detail(fault); Element[] darray = fault.getFaultDetails(); for(int i = 0; i < darray.length; i++) { Element detailtEntryElem = darray[i]; DetailEntry detailEntry = detail.addDetailEntry( new PrefixedQName(detailtEntryElem.getNamespaceURI(), detailtEntryElem.getLocalName(), detailtEntryElem.getPrefix())); copyChildren(detailEntry, detailtEntryElem); } return detail; } -------- private static void copyChildren(SOAPElement soapElement, Element domElement) throws SOAPException { org.w3c.dom.NodeList nl = domElement.getChildNodes(); for(int j = 0; j < nl.getLength(); j++) { org.w3c.dom.Node childNode = nl.item(j); if(childNode.getNodeType() == Node.TEXT_NODE) { soapElement.addTextNode(childNode.getNodeValue()); break; // only one text node assmed } if(childNode.getNodeType() == Node.ELEMENT_NODE) { String uri = childNode.getNamespaceURI(); SOAPElement childSoapElement = null; if(uri == null) { childSoapElement = soapElement.addChildElement(childNode.getLocalName ()); } else { childSoapElement = soapElement.addChildElement( childNode.getLocalName(), childNode.getPrefix(), uri); } copyChildren(childSoapElement, (Element)childNode); } } } ======================================================================== Finaly, the source of the test client is: ======================================================================== package unit.test; import java.io.Reader; import java.io.FileReader; import org.xml.sax.InputSource; import org.apache.axis.encoding.DeserializationContext; import org.apache.axis.encoding.DeserializationContextImpl; import org.apache.axis.server.AxisServer; import org.apache.axis.*; import org.apache.axis.message.*; public class DetailTest { private String _fileName; private MessageContext _msgContext; public DetailTest(String fileName) { _fileName = fileName; _msgContext = new MessageContext(new AxisServer()); } public static void main(String[] args) throws Exception { if(args.length < 1) { System.out.println("Usage: java " + DetailTest.class.getName() + " SOAP-error-reply-file"); return; } DetailTest detailTest = new DetailTest(args[0]); detailTest.run(); } private void run() throws Exception { Reader reader = new FileReader(_fileName); InputSource src = new InputSource(reader); SOAPBodyElement bodyItem = getFirstBody(src); SOAPFault flt = (SOAPFault)bodyItem; javax.xml.soap.Detail d = flt.getDetail(); System.out.println("Got detail"); } private SOAPBodyElement getFirstBody(InputSource msgSource) throws Exception { DeserializationContext dser = new DeserializationContextImpl( msgSource, _msgContext, Message.RESPONSE); dser.parse(); SOAPEnvelope env = dser.getEnvelope(); return env.getFirstBody(); } }