List of usage examples for javax.xml.ws.soap SOAPFaultException getFault
public javax.xml.soap.SOAPFault getFault()
From source file:com.moss.greenshell.wizard.catastrophe.PostMortemScreen.java
public static void submitErrorReport(final Throwable cause, final ErrorReportDecorator... decorators) throws Exception { List<ErrorReportChunk> chunks = new LinkedList<ErrorReportChunk>(); try {/*from ww w .ja va2s. co m*/ if (cause instanceof InternalErrorException) { InternalErrorException ie = (InternalErrorException) cause; ErrorReportChunk chunk = new ErrorReportChunk("internal-error-id", "text/plain", ie.id().getBytes("UTF8")); chunks.add(chunk); } else if (cause instanceof SOAPFaultException) { SOAPFaultException soapFault = (SOAPFaultException) cause; String content = soapFault.getFault().getFirstChild().getTextContent(); String prefix = "Internal Service Error Occurred: "; if (content.startsWith(prefix)) { String id = content.substring(prefix.length()); ErrorReportChunk chunk = new ErrorReportChunk("internal-error-id", "text/plain", id.getBytes("UTF8")); chunks.add(chunk); } } } catch (Throwable t) { t.printStackTrace(); } // STACK TRACE ByteArrayOutputStream stackBytes = new ByteArrayOutputStream(); PrintStream stackPrintStream = new PrintStream(stackBytes); cause.printStackTrace(stackPrintStream); stackPrintStream.close(); stackBytes.close(); ErrorReportChunk chunk = new ErrorReportChunk("stack trace", "text/plain", stackBytes.toByteArray()); chunks.add(chunk); // THREAD DUMP ByteArrayOutputStream dumpBytes = new ByteArrayOutputStream(); PrintStream out = new PrintStream(dumpBytes); Map<Thread, StackTraceElement[]> traceMap = Thread.getAllStackTraces(); for (Map.Entry<Thread, StackTraceElement[]> next : traceMap.entrySet()) { out.println(); out.println(next.getKey().getName()); for (StackTraceElement line : next.getValue()) { String className = emptyIfNull(line.getClassName()); String methodName = emptyIfNull(line.getMethodName()); String fileName = emptyIfNull(line.getFileName()); out.println(" " + className + "." + methodName + " (" + fileName + " line " + line.getLineNumber() + ")"); } } out.flush(); out.close(); ErrorReportChunk stackDump = new ErrorReportChunk("thread dump", "text/plain", dumpBytes.toByteArray()); chunks.add(stackDump); // SYSTEM PROPERTIES ByteArrayOutputStream propsBytes = new ByteArrayOutputStream(); PrintStream propsOut = new PrintStream(propsBytes); for (Map.Entry<Object, Object> next : System.getProperties().entrySet()) { propsOut.println(" " + next.getKey() + "=" + next.getValue()); } propsOut.flush(); propsOut.close(); chunks.add(new ErrorReportChunk("system properties", "text/plain", propsBytes.toByteArray())); // LOCAL CLOCK chunks.add(new ErrorReportChunk("local clock", "text/plain", new DateTime().toString().getBytes())); // NETWORKING StringBuffer networking = new StringBuffer(); Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); networking.append("INTERFACE: " + iface.getName() + " (" + iface.getDisplayName() + ")\n"); Enumeration<InetAddress> addresses = iface.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress address = addresses.nextElement(); networking.append(" Address:" + address.getHostAddress() + "\n"); networking.append(" Cannonical Host Name: " + address.getCanonicalHostName() + "\n"); networking.append(" Host Name: " + address.getHostName() + "\n"); } } chunks.add(new ErrorReportChunk("network configuration", "text/plain", networking.toString().getBytes())); // DECORATORS if (decorators != null) { for (ErrorReportDecorator decorator : decorators) { chunks.addAll(decorator.makeChunks(cause)); } } ErrorReport report = new ErrorReport(chunks); Reporter reporter = new Reporter(); ReportId id = reporter.submitReport(report); }
From source file:com.palominolabs.crm.sf.soap.MetadataConnectionImplTest.java
License:asdf
private static void assertInvalidSession(ApiException e) { assertEquals("Call failed", e.getMessage()); Throwable cause = e.getCause(); assertTrue(cause instanceof SOAPFaultException); SOAPFaultException soapFaultException = (SOAPFaultException) cause; String expectedMsg = "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key: "; String actualMsg = soapFaultException.getMessage(); assertEquals(expectedMsg, truncateSessionId(actualMsg)); SOAPFault fault = soapFaultException.getFault(); QName codeQname = fault.getFaultCodeAsQName(); assertEquals("INVALID_SESSION_ID", codeQname.getLocalPart()); String faultMsg = fault.getFaultString(); assertEquals(expectedMsg, truncateSessionId(faultMsg)); }
From source file:de.extra.extraClientLight.util.SendWebService.java
/** * /*from w w w.j a v a2 s. co m*/ * @param extraRequest * @param url * @param mtomActive * @return */ public TransportResponseType sendRequest(TransportRequestType extraRequest, String url, boolean mtomActive) { TransportResponseType response = new TransportResponseType(); Extra_Service extraService = new Extra_Service(null, SERVICE_NAME); Extra extraPort = extraService.getPort(Extra.class); BindingProvider bp = (BindingProvider) extraPort; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); SOAPBinding soapBinding = (SOAPBinding) bp.getBinding(); soapBinding.setMTOMEnabled(mtomActive); try { LOGGER.debug("Versand gestartet..."); response = extraPort.execute(extraRequest); LOGGER.debug("...Empfang Response"); if (mtomActive) { Collection<Attachment> attachmentList = (Collection<Attachment>) bp.getResponseContext() .get(Message.ATTACHMENTS); LOGGER.debug("Attachments: " + attachmentList.size()); } } catch (SOAPFaultException e) { SOAPFault soapFault = e.getFault(); LOGGER.error(soapFault.getTextContent(), e); } catch (ExtraFault e) { ExtraErrorHelper.printExtraError(e); } return response; }
From source file:com.javector.soaj.provider.generatedwsdl.TestProviderGeneratedWsdl.java
public void testProvider() throws Exception { SoajProviderService service = new SoajProviderService(); SoajProviderPortType port = service.getSoajProviderPort(); Item item = new Item(); item.setPrice(3.99);/*from ww w . j a v a 2s . c om*/ item.setProductName("Diet Coke"); item.setQuantity(BigInteger.valueOf(6)); Items items = new Items(); items.getItem().add(item); BillToType billTo = new BillToType(); billTo.setCity("Canton"); billTo.setPhone("(973) 243-8776"); billTo.setState("OH"); billTo.setStreet("125 Main Street"); billTo.setZip("98134"); PurchaseOrder po = new PurchaseOrder(); po.setBillTo(billTo); po.setItems(items); BillToType response; try { response = port.getBillTo(po); } catch (SOAPFaultException sfe) { SOAPFault sf = sfe.getFault(); System.out.println("SOAPFault:" + IOUtil.NL + XmlUtil.toFormattedString(sf)); sf.getDetail(); throw sfe; } assertNotNull("SOAP Response should not be null.", response); System.out.println("bill to city = " + response.getCity()); assertEquals("Canton", response.getCity()); }
From source file:com.javector.soaj.provider.generatedwsdl.TestProviderGeneratedWsdl.java
public void testProviderEJB21Invocation() throws Exception { SoajProviderService service = new SoajProviderService(); SoajProviderPortType port = service.getSoajProviderPort(); Item item = new Item(); item.setPrice(3.99);/*from w ww .jav a 2 s .c o m*/ item.setProductName("Diet Coke"); item.setQuantity(BigInteger.valueOf(6)); Items items = new Items(); items.getItem().add(item); BillToType billTo = new BillToType(); billTo.setCity("Canton"); billTo.setPhone("(973) 243-8776"); billTo.setState("OH"); billTo.setStreet("125 Main Street"); billTo.setZip("98134"); PurchaseOrder po = new PurchaseOrder(); po.setBillTo(billTo); po.setItems(items); BillToType response; try { response = port.getBillToFromEJB21(po); } catch (SOAPFaultException sfe) { SOAPFault sf = sfe.getFault(); System.out.println("SOAPFault:" + IOUtil.NL + XmlUtil.toFormattedString(sf)); sf.getDetail(); throw sfe; } assertNotNull("SOAP Response should not be null.", response); System.out.println("bill to city = " + response.getCity()); assertEquals("Canton", response.getCity()); }
From source file:se.inera.axel.riv2ssek.internal.RivSsekRouteBuilderTest.java
@Test public void sendRegisterMedicalCertificateWithUnknownReceiverId() { ssekRegisterMedicalCertificate//ww w .j ava2 s . c o m .whenAnyExchangeReceived(httpResponse(HttpServletResponse.SC_OK, SSEK_FAULT_RECEIVERIDUNKNOWN)); RegisterMedicalCertificateResponderInterface registerMedicalCertificateResponderPort = getRegisterMedicalCertificateResponderInterface(); RegisterMedicalCertificateType registerMedicalCertificateType = new RegisterMedicalCertificateType(); AttributedURIType to = new AttributedURIType(); to.setValue("1111111111"); try { registerMedicalCertificateResponderPort.registerMedicalCertificate(to, registerMedicalCertificateType); fail("Should have thrown Soap fault"); } catch (SOAPFaultException e) { assertEquals(e.getFault().getFaultActor(), "Prisma@SESTVER53"); assertEquals(e.getFault().getFaultCodeAsQName().getNamespaceURI(), "http://schemas.ssek.org/ssek/2006-05-10/"); assertEquals(e.getFault().getFaultCodeAsQName().getLocalPart(), "ReceiverIdUnknown"); } }
From source file:com.legstar.proxy.invoke.jaxws.WebServiceInvoker.java
/** * Try to extract something meaningful from a SOAP Fault. * //from w w w . java 2 s.c om * @param e the SOAP Fault exception * @return a fault description */ @SuppressWarnings("rawtypes") public String getFaultReasonText(final SOAPFaultException e) { if (_log.isDebugEnabled()) { SOAPFault fault = e.getFault(); if (fault != null) { QName code = fault.getFaultCodeAsQName(); String string = fault.getFaultString(); String actor = fault.getFaultActor(); _log.debug("SOAP fault contains: "); _log.debug(" Fault code = " + code.toString()); _log.debug(" Local name = " + code.getLocalPart()); _log.debug(" Namespace prefix = " + code.getPrefix() + ", bound to " + code.getNamespaceURI()); _log.debug(" Fault string = " + string); if (actor != null) { _log.debug(" Fault actor = " + actor); } Detail detail = fault.getDetail(); if (detail != null) { Iterator entries = detail.getDetailEntries(); while (entries.hasNext()) { DetailEntry newEntry = (DetailEntry) entries.next(); String value = newEntry.getValue(); _log.debug(" Detail entry = " + value); } } } else { _log.debug(e); } } SOAPFault fault = e.getFault(); if (fault != null) { StringBuffer faultMessage = new StringBuffer(e.getFault().getFaultString()); Detail detail = fault.getDetail(); if (detail != null) { Iterator entries = detail.getDetailEntries(); while (entries.hasNext()) { DetailEntry newEntry = (DetailEntry) entries.next(); faultMessage.append(" [" + newEntry.getValue() + "]"); } } return faultMessage.toString(); } else { return e.getMessage(); } }
From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java
protected void assertSoapFault(SOAPFaultException e, String expectedCode, String expectedMessage) { SOAPFault fault = e.getFault(); String faultCode = fault.getFaultCode(); display("SOAP fault code: " + faultCode); assertTrue("Unexpected fault code: " + faultCode, faultCode.endsWith(expectedCode)); String message = e.getMessage(); assertTrue("Unexpected fault message: " + message, message.contains(expectedMessage)); }
From source file:org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.java
/** * This method is used by WebService Impl and Provider to create an XMLFault (for marshalling) * from an exception that is a non-service exception * * @param t Throwable that represents a Service Exception * @return XMLFault//ww w . java 2 s . co m */ public static XMLFault createXMLFaultFromSystemException(Throwable t) { try { XMLFault xmlfault = null; if (t instanceof SOAPFaultException) { if (log.isErrorEnabled()) { log.debug("Marshal SOAPFaultException"); } // Category C: SOAPFaultException // Construct the xmlFault from the SOAPFaultException's Fault SOAPFaultException sfe = (SOAPFaultException) t; SOAPFault soapFault = sfe.getFault(); if (soapFault == null) { // No fault ? I will treat this like category E xmlfault = new XMLFault(null, // Use the default XMLFaultCode new XMLFaultReason(t.toString())); // Assumes text lang of current Locale } else { xmlfault = XMLFaultUtils.createXMLFault(soapFault); } } else if (t instanceof WebServiceException) { if (log.isErrorEnabled()) { log.debug("Marshal as a WebServiceException"); } // Category D: WebServiceException // The reason is constructed with the getMessage of the exception. // There is no detail WebServiceException wse = (WebServiceException) t; // Get the fault text using algorithm defined in JAX-WS 10.2.2.3 String text = wse.getMessage(); if (text == null || text.length() == 0) { text = wse.toString(); } xmlfault = new XMLFault(null, // Use the default XMLFaultCode new XMLFaultReason(text)); // Assumes text lang of current Locale } else { if (log.isErrorEnabled()) { log.debug("Marshal as a unchecked System Exception"); } // Category E: Other System Exception // The reason is constructed with the toString of the exception. // This places the class name of the exception in the reason // There is no detail. // Get the fault text using algorithm defined in JAX-WS 10.2.2.3 String text = t.getMessage(); if (text == null || text.length() == 0) { text = t.toString(); } xmlfault = new XMLFault(null, // Use the default XMLFaultCode new XMLFaultReason(text)); // Assumes text lang of current Locale } return xmlfault; } catch (Throwable e) { try { // If an exception occurs while demarshalling an exception, // then rinse and repeat with a webservice exception if (log.isDebugEnabled()) { log.debug("An exception (" + e + ") occurred while marshalling exception (" + t + ")"); } // Get the fault text using algorithm defined in JAX-WS 10.2.2.3 String text = e.getMessage(); if (text == null || text.length() == 0) { text = e.toString(); } WebServiceException wse = ExceptionFactory.makeWebServiceException(e); return new XMLFault(null, // Use the default XMLFaultCode new XMLFaultReason(text)); // Assumes text lang of current Locale } catch (Exception e2) { // Exception while creating Exception for Exception throw ExceptionFactory.makeWebServiceException(e2); } } }
From source file:org.apache.juddi.v3.client.mapping.MapUDDIv2Tov3.java
public static DispositionReportFaultMessage MapException(SOAPFaultException ex) { org.uddi.api_v3.DispositionReport r = new org.uddi.api_v3.DispositionReport(); r.setTruncated(false);/*from w w w .j a v a 2 s .c om*/ r.getResult().addAll(MapFault(ex.getFault())); DispositionReportFaultMessage x = new DispositionReportFaultMessage(ex.getMessage(), r); return x; }