方法
getNodeValue
会一直回来的
null
对于dom元素,
getTextContent
更好,但在您的情况下,所有信息都包含在嵌套元素的属性中。您必须使用如下代码遍历这些嵌套元素。请注意,我还没有测试代码。
String uri = "http://jax-ws.dev.java.net/";
QName qnException = new QName(uri, "exception");
QName qnStackTrace = new QName(uri, "stackTrace");
QName qnFrame = new QName(uri, "frame");
SOAPFault fault = soapMsg.getSOAPBody().getFault();
System.out.println("code=" + fault.getFaultCode());
System.out.println("faultString=" + fault.getFaultString());
for (Iterator i=fault.getDetail().getDetailEntries(); i.hasNext(); ) {
DetailEntry detailEntry = (DetailEntry)i.next();
for (Iterator j=detailEntry.getChildElements(qnException); j.hasNext(); ) {
SOAPElement exception = (SOAPElement)j.next();
System.out.println("exception class=" + exception.getAttribute("class"));
for (Iterator k=exception.getChildElements(qnStackTrace); k.hasNext(); ) {
SOAPElement stackTrace = (SOAPElement)k.next();
for (Iterator l=stackTrace.getChildElements(qnFrame); l.hasNext(); ) {
SOAPElement frame = (SOAPElement)l.next();
System.out.println(" class=" + frame.getAttribute("class"));
System.out.println(" file =" + frame.getAttribute("file"));
}
}
}
}