protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) { if (ex instanceof BusinessItcbException) { BusinessItcbException bie = (BusinessItcbException) ex; SoapFaultDetail detail = fault.addFaultDetail(); detail.addFaultDetailElement(BusinessItcbException.EXCEPTION_CLASS).addText(ex.getClass().getName()); detail.addFaultDetailElement(BusinessItcbException.COMMON_MESSAGE).addText(bie.getMessage()); } }
private void makeBusinessItcbException(SoapFaultClientException sfce) { try { while(sfce.getSoapFault().getFaultDetail().getDetailEntries().hasNext()) { SoapFaultDetailElement saajSoapFaultDetailElement = sfce.getSoapFault().getFaultDetail().getDetailEntries().next(); if(saajSoapFaultDetailElement.getName().getLocalPart().equals(BusinessItcbException.EXCEPTION_CLASS.getLocalPart())) { if(saajSoapFaultDetailElement.getResult() instanceof DOMResult) { String exceptionClassName = ((DOMResult)saajSoapFaultDetailElement.getResult()).getNode().getTextContent(); Class<?> exceptionClass = Class.forName(exceptionClassName); Constructor<?>[] constructors= exceptionClass.getConstructors(); for (Constructor<?> constructor : constructors) { if(constructor.getParameterTypes().length == 2) { Class<?> classErrorMapping = constructor.getParameterTypes()[0]; BusinessItcbException bie = (BusinessItcbException)constructor.newInstance( classErrorMapping.getMethod("valueOf", String.class).invoke(classErrorMapping, sfce.getFaultCode().getLocalPart()) , sfce.getLocalizedMessage()); throw bie; } } } } } } catch(BusinessItcbException bie) { throw bie; } // No mapping found catch(Throwable t) { t.printStackTrace(); throw new ClientItcbException(ClientItcbExceptionMappingErrors.COMMON_CLIENT_BUSINESS_TRANSFORMATION_ERROR, messageSource.getMessage("common-client.exception.resolver.transformation_error", new Object[] {t.getMessage()}, LocaleContextHolder.getLocale())); } }
/** * Gets exception from fault detail. * <p/> * If there is no fault detail then no exception is returned. * If there is no supported exception in fault detail then {@link IntegrationException} is returned. * * @param faultDetail the fault detail * @return exception */ @Nullable private Exception getFaultException(@Nullable SoapFaultDetail faultDetail) { if (faultDetail != null) { DOMSource detailSource = (DOMSource) faultDetail.getSource(); Node detailNode = detailSource.getNode(); QName exName = getExceptionName(detailNode); Exception exception = createException(exName, detailNode); if (exception == null) { // throws common exception with specified exception exception = new IntegrationException(getErrorCodeForException(null), exName.getLocalPart()); } return exception; } return null; }
transformer.transform(new StringSource(soapFaultDetails.get(i)), faultDetail.getResult());
/** * Adds error code element detail into SOAP fault. * * @param messageContext current message context * @param endpoint the executed endpoint, or <code>null</code> if none chosen at the time of the exception * @param ex the exception that got thrown during endpoint execution * @param fault the SOAP fault to be customized. */ protected void customizeFault(MessageContext messageContext, Object endpoint, Exception ex, SoapFault fault) { if (ex instanceof IntegrationException) { SoapFaultDetail detail = fault.addFaultDetail(); detail.addFaultDetailElement(ERR_CODE).addText(((IntegrationException) ex).getError().getErrorCode()); } } }
private void manageOtherSpecificSoapFaultClientException(SoapFaultClientException sfce) { //ValidationError if(sfce.getSoapFault().getFaultDetail() != null) { try { while(sfce.getSoapFault().getFaultDetail().getDetailEntries().hasNext()) { SoapFaultDetailElement saajSoapFaultDetailElement = sfce.getSoapFault().getFaultDetail().getDetailEntries().next(); if(saajSoapFaultDetailElement.getName().getNamespaceURI().equals(SPRING_WS_URI) && saajSoapFaultDetailElement.getName().getLocalPart().equals(SPRING_WS_VALIDATION_ERROR)) { if(saajSoapFaultDetailElement.getResult() instanceof DOMResult) { String detailedMessage = ((DOMResult)saajSoapFaultDetailElement.getResult()).getNode().getTextContent(); throw new ClientItcbException(ClientItcbExceptionMappingErrors.COMMON_CLIENT_VALIDATION_ERROR, messageSource.getMessage("common-client.exception.validation_error", new Object[] {detailedMessage}, LocaleContextHolder.getLocale())); } } } } catch(ClientItcbException cie) { throw cie; } } }
SoapFaultDetail detail = fault.addFaultDetail(); for (SAXParseException error : errors) { SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(error.getMessage());
private void manageOtherSpecificSoapFaultClientException(SoapFaultClientException sfce) { //ValidationError if(sfce.getSoapFault().getFaultDetail() != null) { try { Iterator<SoapFaultDetailElement> iteratorDetailEntries = sfce.getSoapFault().getFaultDetail().getDetailEntries(); while(iteratorDetailEntries.hasNext()) { SoapFaultDetailElement soapFaultDetailElement = iteratorDetailEntries.next(); if(soapFaultDetailElement.getName().getNamespaceURI().equals(SPRING_WS_URI) && soapFaultDetailElement.getName().getLocalPart().equals(SPRING_WS_VALIDATION_ERROR)) { if(soapFaultDetailElement.getResult() instanceof DOMResult) { String detailedMessage = ((DOMResult)soapFaultDetailElement.getResult()).getNode().getTextContent(); throw new ClientItcbException(ClientItcbExceptionMappingErrors.COMMON_CLIENT_VALIDATION_ERROR, messageSource.getMessage("common-client.exception.validation_error", new Object[] {detailedMessage}, LocaleContextHolder.getLocale())); } } } } catch(ClientItcbException cie) { throw cie; } } }
SoapFaultDetail detail = fault.addFaultDetail(); for (SAXParseException error : errors) { SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(error.getMessage());
private void makeBusinessItcbException(SoapFaultClientException sfce) { try { while(sfce.getSoapFault().getFaultDetail().getDetailEntries().hasNext()) { SoapFaultDetailElement soapFaultDetailElement = sfce.getSoapFault().getFaultDetail().getDetailEntries().next(); if(soapFaultDetailElement.getName().getLocalPart().equals(BusinessItcbException.EXCEPTION_CLASS.getLocalPart())) { if(soapFaultDetailElement.getResult() instanceof DOMResult) {
SoapFaultDetail detail = fault.addFaultDetail(); for (SAXParseException error : errors) { SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(error.getMessage());
/** * Builder method from Spring WS SOAP fault object. * @param fault * @return */ public static SoapFault from(org.springframework.ws.soap.SoapFault fault) { QNameEditor qNameEditor = new QNameEditor(); qNameEditor.setValue(fault.getFaultCode()); SoapFault soapFault = new SoapFault() .faultCode(qNameEditor.getAsText()) .faultActor(fault.getFaultActorOrRole()) .faultString(fault.getFaultStringOrReason()); if (fault.getFaultDetail() != null) { Iterator<SoapFaultDetailElement> details = fault.getFaultDetail().getDetailEntries(); while (details.hasNext()) { SoapFaultDetailElement soapFaultDetailElement = details.next(); soapFault.addFaultDetail(extractFaultDetail(soapFaultDetailElement)); } } return soapFault; }
SoapFaultDetail detail = fault.addFaultDetail(); for (SAXParseException error : errors) { SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(error.getMessage());
for (ObjectError objectError : errors.getAllErrors()) { String msg = messageSource.getMessage(objectError, getFaultLocale()); SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(msg);
for (ObjectError objectError : errors.getAllErrors()) { String msg = messageSource.getMessage(objectError, getFaultLocale()); SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(msg);
for (ObjectError objectError : errors.getAllErrors()) { String msg = messageSource.getMessage(objectError, getFaultLocale()); SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(msg);
for (ObjectError objectError : errors.getAllErrors()) { String msg = messageSource.getMessage(objectError, getFaultLocale()); SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(msg);
/** * Template method that is called when the request SOAP headers contains validation errors. * Default implementation logs all errors, and returns <code>false</code>, i.e. do not process the request. * * @param messageContext the message context * @param errors the validation errors * @return <code>true</code> to continue processing the request, <code>false</code> (the default) otherwise * @throws TransformerException if error occurs during the transformation process */ protected boolean handleHeaderValidationErrors(MessageContext messageContext, ValidationException[] errors) throws TransformerException { for (ValidationException error : errors) { logger.warn("XML validation error on request: " + error.getMessage()); } if (messageContext.getResponse() instanceof SoapMessage) { SoapMessage response = (SoapMessage) messageContext.getResponse(); SoapBody body = response.getSoapBody(); SoapFault fault = body.addClientOrSenderFault(faultHeaderStringOrReason, getFaultStringOrReasonLocale()); if (getAddValidationErrorDetail()) { SoapFaultDetail detail = fault.addFaultDetail(); for (ValidationException error : errors) { SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName()); detailElement.addText(error.getMessage()); } } } return false; }