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())); } }
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; } } }
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; } } }
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) {
/** * 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; }