Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not an expert for Websphere and cannot tell you whether there is a configuration option that lets you do this.</p> <blockquote> <p>or is there way how to add it manually (not by creating custom element)?</p> </blockquote> <p>You can always add details and modify the fault string and code in your web service when you throw the fault. Now, there are many ways to construct and throw the fault and I do not know how your web service does it. Here is a very simple example that puts the stack trace of an exception into the fault string.</p> <pre><code> @WebMethod public void throwFault(){ try { SOAPFactory factory = SOAPFactory.newInstance(); IndexOutOfBoundsException e = new IndexOutOfBoundsException("index out of bounds"); SOAPFault fault = factory.createFault(getStackTraceString(e), new QName("http://whatever.com","CustomFault")); throw new SOAPFaultException(fault); } catch (SOAPException e) { // ignore for the example } } private String getStackTraceString(Exception e){ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); return sw.toString(); } </code></pre> <p>The method <code>throwFault</code> is exposed by the service and simply creates and throws a new <code>SOAPFault</code>. This may look different in your code. The private method <code>getStackTraceString</code> converts the stack trace into a String representation.</p> <p>This solution does add an additional element to your WSDL, it simply reuses the fault string for the stack trace.</p> <p>Calling the web service, I get the following response:</p> <pre><code> &lt;S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;S:Body&gt; &lt;S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope"&gt; &lt;faultcode xmlns:ns0="http://whatever.com"&gt;ns0:CustomFault&lt;/faultcode&gt; &lt;faultstring&gt;java.lang.IndexOutOfBoundsException: index out of bounds at Faulter.throwUndeclaredFault(Faulter.java:23) at &lt;!--rest of stacktrace omitted for readability--!&gt; &lt;/faultstring&gt; &lt;/S:Fault&gt; &lt;/S:Body&gt; &lt;/S:Envelope&gt; </code></pre> <p>EDIT: Assuming that the variable <code>error</code> in your code is an exception, you can change your throw statement to</p> <pre><code>throw new CustomException(getStackTraceString(error),error); </code></pre> <p>This should provide you with the stack trace in a fashion as described above.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload