File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes How to throw a customised SOAPFaultException Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to throw a customised SOAPFaultException Exception" Watch "How to throw a customised SOAPFaultException Exception" New topic
Author

How to throw a customised SOAPFaultException Exception

Shivashankar Gurumurthy
Greenhorn

Joined: Feb 26, 2005
Posts: 12
I want to throw a customised soap fault exception from my code. I have the fault code , fault string, fault actor and fault detail to be set in that. When i create a detail object and test my application i am getting a null pointer exception.

I am developing a webservice in WSAD. Can anybody help me out by telling how to create a detail object and set my fault detail into that and throw a new soap fault exception with those 4 arguements. If there is any previous thread running about this then somebody please let me know.

The stack trace follows

[3/10/06 23:23:03:170 IST] 5faa5faa WebServicesSe E com.ibm.ws.webservices.engine.transport.http.WebServicesServlet WSWS3227E: Error: Exception:
[3/10/06 23:23:03:217 IST] 5faa5faa WebServicesSe E com.ibm.ws.webservices.engine.transport.http.WebServicesServlet TRAS0014I: The following exception was logged WebServicesFault
faultCode: Server.generalException
faultString: com.ibm.ws.webservices.engine.InternalException: java.lang.NullPointerException
faultActor: null
faultDetail:

com.ibm.ws.webservices.engine.InternalException: java.lang.NullPointerException
com.ibm.ws.webservices.engine.InternalException: java.lang.NullPointerException
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java)
at com.ibm.ws.webservices.engine.InternalException.<init>(InternalException.java:132)
at com.ibm.ws.webservices.engine.xmlsoap.SOAPElement.asSOAPElement(SOAPElement.java)
at com.ibm.ws.webservices.engine.xmlsoap.SOAPElement.getChildElements(SOAPElement.java:503)
at com.ibm.ws.webservices.engine.xmlsoap.Detail.getDetailEntries(Detail.java:127)
at com.ibm.ws.webservices.engine.WebServicesFault.<init>(WebServicesFault.java:238)
at com.ibm.ws.webservices.engine.WebServicesFault.makeFault(WebServicesFault.java:147)
at com.ibm.ws.webservices.engine.providers.java.JavaProvider.invoke(JavaProvider.java:294)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:61)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:255)
at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:850)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
Welcome to JavaRanch.

The Web Services FAQ links to this article, which explains how to do that.


Ping & DNS - my free Android networking tools app
Shivashankar Gurumurthy
Greenhorn

Joined: Feb 26, 2005
Posts: 12
Originally posted by shivashankar gurumurthy:
I want to throw a customised soap fault exception from my code. I have the fault code , fault string, fault actor and fault detail to be set in that. When i create a detail object and test my application i am getting a null pointer exception.

I am developing a webservice in WSAD. Can anybody help me out by telling how to create a detail object and set my fault detail into that and throw a new soap fault exception with those 4 arguements. If there is any previous thread running about this then somebody please let me know.

The stack trace follows

[3/10/06 23:23:03:170 IST] 5faa5faa WebServicesSe E com.ibm.ws.webservices.engine.transport.http.WebServicesServlet WSWS3227E: Error: Exception:
[3/10/06 23:23:03:217 IST] 5faa5faa WebServicesSe E com.ibm.ws.webservices.engine.transport.http.WebServicesServlet TRAS0014I: The following exception was logged WebServicesFault
faultCode: Server.generalException
faultString: com.ibm.ws.webservices.engine.InternalException: java.lang.NullPointerException
faultActor: null
faultDetail:

com.ibm.ws.webservices.engine.InternalException: java.lang.NullPointerException
com.ibm.ws.webservices.engine.InternalException: java.lang.NullPointerException
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java)
at com.ibm.ws.webservices.engine.InternalException.<init>(InternalException.java:132)
at com.ibm.ws.webservices.engine.xmlsoap.SOAPElement.asSOAPElement(SOAPElement.java)
at com.ibm.ws.webservices.engine.xmlsoap.SOAPElement.getChildElements(SOAPElement.java:503)
at com.ibm.ws.webservices.engine.xmlsoap.Detail.getDetailEntries(Detail.java:127)
at com.ibm.ws.webservices.engine.WebServicesFault.<init>(WebServicesFault.java:238)
at com.ibm.ws.webservices.engine.WebServicesFault.makeFault(WebServicesFault.java:147)
at com.ibm.ws.webservices.engine.providers.java.JavaProvider.invoke(JavaProvider.java:294)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:61)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:212)
at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:255)
at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:850)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)
.



Hi,

I have done this already, but i got NullPointerException while creating Detail object even with any single element added to it. Is it a problem with IBM Websphere server?. if so then is there any other way round to get it done??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
Now we've seen the stack trace twice, but still don't know what the code is doing when the exception is thrown. Why don't you post a short, relevant excerpt for us to look at (and please, don't quote your original post again).
Shivashankar Gurumurthy
Greenhorn

Joined: Feb 26, 2005
Posts: 12
Hi,
This is my problem.
I try to throw a new SOAPFult exception from my catch block. I went to the site that is mentioned in your reply. i am throwing an exception in the same way the site is telling one to do. I created a detail object in order to place my fault detail inside that. Then in order to check whether exception is thrown atleast with a empty detail in it i tested the app. It is throwing a null pointer exception as shown in stack trace. if i throw a SOAPFult exception with detail as null it works. but the moment i create a detail object (in the sense only the detail creation code is present and no values are added to the detail) i get a null pointer generated from somewhere inside the auto generated system classes.
Please advise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to throw a customised SOAPFaultException Exception