List of usage examples for javax.xml.soap SOAPException getCause
@Override
public Throwable getCause()
From source file:test.functional.TestJAXMSamples.java
public void testDelayedStockQuote() throws Exception { try {//from w ww . j a v a2s. c o m log.info("Testing JAXM DelayedStockQuote sample."); DelayedStockQuote stockQuote = new DelayedStockQuote(); System.out.print("The last price for SUNW is " + stockQuote.getStockQuote("SUNW")); log.info("Test complete."); } catch (javax.xml.soap.SOAPException e) { Throwable t = e.getCause(); if (t != null) { t.printStackTrace(); if (t instanceof AxisFault) { AxisFault af = (AxisFault) t; if ((af.detail instanceof SocketException) || (af.getFaultCode().getLocalPart().equals("HTTP"))) { System.out.println("Connect failure caused JAXM DelayedStockQuote to be skipped."); return; } } throw new Exception("Fault returned from test: " + t); } else { e.printStackTrace(); throw new Exception("Exception returned from test: " + e); } } catch (Throwable t) { t.printStackTrace(); throw new Exception("Fault returned from test: " + t); } }
From source file:test.functional.TestJAXMSamples.java
public void testJWSFault() throws Exception { try {// www. ja v a 2 s. c o m SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance(); SOAPConnection con = scFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); SOAPBody body = envelope.getBody(); Name bodyName = envelope.createName("echo"); SOAPBodyElement bodyElement = body.addBodyElement(bodyName); Name name = envelope.createName("arg0"); SOAPElement symbol = bodyElement.addChildElement(name); symbol.addTextNode("Hello"); URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/jws/FaultTest.jws"); SOAPMessage response = con.call(message, endpoint); SOAPBody respBody = response.getSOAPPart().getEnvelope().getBody(); assertTrue(respBody.hasFault()); } catch (javax.xml.soap.SOAPException e) { Throwable t = e.getCause(); if (t != null) { t.printStackTrace(); if (t instanceof AxisFault) { AxisFault af = (AxisFault) t; if ((af.detail instanceof SocketException) || (af.getFaultCode().getLocalPart().equals("HTTP"))) { System.out.println("Connect failure caused testJWSFault to be skipped."); return; } } throw new Exception("Fault returned from test: " + t); } else { e.printStackTrace(); throw new Exception("Exception returned from test: " + e); } } catch (Throwable t) { t.printStackTrace(); throw new Exception("Fault returned from test: " + t); } }