This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes Sample java code to retrieve AxisFault from InvocationTargetException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Sample java code to retrieve AxisFault from InvocationTargetException" Watch "Sample java code to retrieve AxisFault from InvocationTargetException" New topic
Author

Sample java code to retrieve AxisFault from InvocationTargetException

lucky Behl
Greenhorn

Joined: Feb 04, 2013
Posts: 3
My InvocationTargetException prints following when did printStackTrace on it:



AxisFault
faultCode: device.could.not.be.created
faultSubcode:
faultString: The Device could not be created
faultActor:
faultNode:
faultDetail:
{http://schemas.xmlsoap.org/soap/envelope/}Fault:<faultcode>device.already.exists</faultcode><faultstring>Device already exists</faultstring>

The Device could not be created
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.motive.www.remotehdm.NBIService._1_0.NBIServicePortStub.createDevice(NBIServicePortStub.java:4846)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at motive.hdm.nbiclientutils.NBIServiceWSClientProxy.invoke(NBIServiceWSClientProxy.java:95)
at $Proxy18.createDevice(Unknown Source)
at motive.datasource.hdm.HDMNBIServiceWrapper.createDevice(HDMNBIServiceWrapper.java:1180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at motive.datasource.hdm.FailSafeAndLoadBalancer.handleHDMConnectionAndInvokeNBIAPIs(FailSafeAndLoadBalancer.java:131)
at motive.datasource.hdm.HDMDriver.execute(HDMDriver.java:84)
at motive.instrumentation.datasourcemgr.DatasourceMgr.execute(DatasourceMgr.java:206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen._cmd__147._c_createDevice_3(<cmd>:69)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen._cmd__147._c_generatedFunction_1(<cmd>:37)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at org.mozilla.javascript.gen._cmd__147._c_script_0(<cmd>:46)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.gen._cmd__147.exec(<cmd>)
at org.mozilla.javascript.Context.evaluateString(Context.java:1111)
at motive.utilities.javascript.JavaScriptImpl.executeString(JavaScriptImpl.java:196)
at motive.instrumentation.datasourcemgr.DatasourceJavaScriptImpl.executeScriptNoCache(DatasourceJavaScriptImpl.java:233)
at motive.instrumentation.datasourcemgr.DatasourceJavaScriptImpl.executeScript(DatasourceJavaScriptImpl.java:161)
at motive.instrumentation.datasourcemgr.DatasourceMgr.executeScript(DatasourceMgr.java:426)
at motive.instrumentation.datasourcemgr.DatasourceMgr.executeScript(DatasourceMgr.java:378)
at motive.instrumentation.PropertyDiscoverable.discover(PropertyDiscoverable.java:340)
at motive.instrumentation.EcosystemDiscoverable.discoverProperty(EcosystemDiscoverable.java:1381)
at motive.instrumentation.EcosystemDiscoverable.discoverProperties(EcosystemDiscoverable.java:396)
at motive.instrumentation.ComponentDiscoverable.doDiscover(ComponentDiscoverable.java:265)
at motive.utilities.Discoverable.discover(Discoverable.java:741)
at motive.instrumentation.EcosystemDiscoverable.discover(EcosystemDiscoverable.java:111)
at motive.instrumentation.EcosystemDiscoverable.discover(EcosystemDiscoverable.java:96)
at motive.utilities.Discoverable.run(Discoverable.java:490)
at motive.java.util.ThreadPool$WorkerThread.run(ThreadPool.java:232)



I would like to retrieve faultcode & faultString from InvocationTargetException: <faultcode>device.already.exists</faultcode> <faultstring>Device already exists</faultstring>
how can i do this??

I tried following:



try {
// here code which throws InvocationFailureException
} catch (InvocationFailureException e) {
Throwable rootCause = e.getRootCause();
if (rootCause instanceof AxisFault) {
AxisFault axFault = (AxisFault)rootCause;
// now extract information, e.g.
axFault.getFaultDetails();
}
}



But only thing i am getting is: "The Device could not be created" Not able to get faultstring i.e. "Device already exists"

How could i retrieve faultString from InvocationTargetException??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sample java code to retrieve AxisFault from InvocationTargetException