Package org.springframework.ws.soap

Examples of org.springframework.ws.soap.SoapFault


        Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse(),
                "SimpleSoapExceptionResolver requires a SoapMessage");
        SoapMessage response = (SoapMessage) messageContext.getResponse();
        String faultString = StringUtils.hasLength(ex.getMessage()) ? ex.getMessage() : ex.toString();
        SoapBody body = response.getSoapBody();
        SoapFault fault = body.addServerOrReceiverFault(faultString, getLocale());
        customizeFault(messageContext, endpoint, ex, fault);
        return true;
    }
View Full Code Here


            logger.warn("Validation error on request object[" + requestObject + "]: " + msg);
        }
        if (messageContext.getResponse() instanceof SoapMessage) {
            SoapMessage response = (SoapMessage) messageContext.getResponse();
            SoapBody body = response.getSoapBody();
            SoapFault fault = body.addClientOrSenderFault(getFaultStringOrReason(), getFaultLocale());
            if (getAddValidationErrorDetail()) {
                SoapFaultDetail detail = fault.addFaultDetail();
                for (ObjectError objectError : errors.getAllErrors()) {
                    String msg = messageSource.getMessage(objectError, getFaultLocale());
                    SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName());
                    detailElement.addText(msg);
                }
View Full Code Here

        String faultStringOrReason = definition.getFaultStringOrReason();
        if (!StringUtils.hasLength(faultStringOrReason)) {
            faultStringOrReason = StringUtils.hasLength(ex.getMessage()) ? ex.getMessage() : ex.toString();
        }
        SoapBody soapBody = ((SoapMessage) messageContext.getResponse()).getSoapBody();
        SoapFault fault;

        if (SoapFaultDefinition.SERVER.equals(definition.getFaultCode()) ||
                SoapFaultDefinition.RECEIVER.equals(definition.getFaultCode())) {
            fault = soapBody.addServerOrReceiverFault(faultStringOrReason, definition.getLocale());
        }
View Full Code Here

            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(getFaultStringOrReason(), getFaultStringOrReasonLocale());
            if (getAddValidationErrorDetail()) {
                SoapFaultDetail detail = fault.addFaultDetail();
                for (SAXParseException error : errors) {
                    SoapFaultDetailElement detailElement = detail.addFaultDetailElement(getDetailElementName());
                    detailElement.addText(error.getMessage());
                }
            }
View Full Code Here

        if (logger.isWarnEnabled()) {
            logger.warn("Could not handle mustUnderstand headers: " +
                    StringUtils.collectionToCommaDelimitedString(notUnderstoodHeaderNames) + ". Returning fault");
        }
        SoapBody responseBody = soapResponse.getSoapBody();
        SoapFault fault =
                responseBody.addMustUnderstandFault(mustUnderstandFaultString, mustUnderstandFaultStringLocale);
        if (!ObjectUtils.isEmpty(actorsOrRoles)) {
            fault.setFaultActorOrRole(actorsOrRoles[0]);
        }
        SoapHeader header = soapResponse.getSoapHeader();
        if (header instanceof Soap12Header) {
            Soap12Header soap12Header = (Soap12Header) header;
            for (QName headerName : notUnderstoodHeaderNames) {
View Full Code Here

    protected boolean handleFaultException(WsSecurityFaultException ex, MessageContext messageContext) {
        if (logger.isWarnEnabled()) {
            logger.warn("Could not handle request: " + ex.getMessage());
        }
        SoapBody response = ((SoapMessage) messageContext.getResponse()).getSoapBody();
        SoapFault fault;
        if (response instanceof Soap11Body) {
            fault = ((Soap11Body) response).addFault(ex.getFaultCode(), ex.getFaultString(), Locale.ENGLISH);
        }
        else {
            fault = response.addClientOrSenderFault(ex.getFaultString(), Locale.ENGLISH);
        }
        fault.setFaultActorOrRole(ex.getFaultActor());
        return false;
    }
View Full Code Here

        assertTrue("Response is not a SOAP message", response instanceof SoapMessage);
        SoapMessage soapResponse = (SoapMessage) response;
        SoapBody responseBody = soapResponse.getSoapBody();
        assertTrue("Response has no SOAP Body", responseBody != null);
        assertTrue("Response has no SOAP Fault", responseBody.hasFault());
        SoapFault soapFault = responseBody.getFault();
        QName expectedFaultCode = getExpectedFaultCode(soapResponse.getVersion());
        assertEquals("Invalid SOAP Fault code", expectedFaultCode, soapFault.getFaultCode());
        if (expectedFaultStringOrReason != null) {
            assertEquals("Invalid SOAP Fault string/reason", expectedFaultStringOrReason,
                    soapFault.getFaultStringOrReason());
        }
    }
View Full Code Here

    }

    @Test
    public void testGetDetailEntriesWorksWithWhitespaceNodes() throws Exception {
        SoapFault fault = failingMessage.getSoapBody().getFault();
        Assert.assertNotNull("Fault is null", fault);
        Assert.assertNotNull("Fault detail is null", fault.getFaultDetail());
        SoapFaultDetail detail = fault.getFaultDetail();
        Assert.assertTrue("No next detail entry present", detail.getDetailEntries().hasNext());
        detail.getDetailEntries().next();

    }
View Full Code Here

    }

    @Test
    public void testGetDetailEntriesWorksWithoutWhitespaceNodes() throws Exception {
        SoapFault fault = succeedingMessage.getSoapBody().getFault();
        Assert.assertNotNull("Fault is null", fault);
        Assert.assertNotNull("Fault detail is null", fault.getFaultDetail());
        SoapFaultDetail detail = fault.getFaultDetail();
        Assert.assertTrue("No next detail entry present", detail.getDetailEntries().hasNext());
        detail.getDetailEntries().next();
    }
View Full Code Here

                result.toString());
    }

    @Test
    public void testAddMustUnderstandFault() throws Exception {
        SoapFault fault = soapBody.addMustUnderstandFault("SOAP Must Understand Error", null);
        assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "MustUnderstand"),
                fault.getFaultCode());
        assertPayloadEqual("<SOAP-ENV:Fault xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>" +
                "<faultcode>" + soapBody.getName().getPrefix() + ":MustUnderstand</faultcode>" +
                "<faultstring>SOAP Must Understand Error</faultstring></SOAP-ENV:Fault>");
    }
View Full Code Here

TOP

Related Classes of org.springframework.ws.soap.SoapFault

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.