Hi,
I have the following problem: I am using SAAJ for web services. I have a SOAPMessage with the following soap fault:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>java.lang.NullPointerException</faultstring>
<detail>
<ns2:exception xmlns:ns2="http://jax-ws.dev.java.net/" class="java.lang.NullPointerException" note="To disable this feature, set com.sun.xml.internal.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false">
<ns2:stackTrace>
<ns2:frame class="myClass" file="HandlerFile.java" line="261" method="invoke" /><ns2:frame class="myClass" file="HandlerFile.java" line="1" method="invoke" /><ns2:frame class="com.sun.xml.internal.ws.api.server.InstanceResolver$1" line="unknown" method="invokeProvider" /></ns2:stackTrace>
</ns2:exception>
</detail>
</S:Fault>
</S:Body>
</S:Envelope>
But if I try to get the details I get nothing!
I do it as follows:
String code = soapMsg.getSOAPBody().getFault().getFaultCode();
String faultString = soapMsg.getSOAPBody().getFault().getFaultString();
Detail detail = reply.getSOAPBody().getFault().getDetail();
if(detail == null)
System.out.println("No detail");
else
System.out.println("Detail value is "+detail.getNodeValue());
Iterator it = reply.getSOAPBody().getFault().getDetail().getDetailEntries();
StringBuilder details = new StringBuilder();
details.append("Detail:");
while(it.hasNext())
{
System.out.println("Has details");
DetailEntry temp = (DetailEntry) it.next();
System.out.println(temp.getTextContent());
System.out.println(temp.getValue());
details.append(temp.getValue());
details.append("-");
Iterator it2 = temp.getChildElements();
while(it2.hasNext())
{
Node t = (Node) it2.next();
System.out.println("Node value:"+t.getNodeValue());
}
}
System.out.println("Details:"+details.toString());
It is printed:
Detail value is null
Has details
Details:null-
Node value:null
Can someone help on this? Why can I not get the details of SOAP fault? It is included in the SOAP message?
UPDATE: The code and the faultstring is printed correctly.
I.e.
code:S:Server
FaultString:java.lang.NullPointerException
Thanks