Package org.springframework.ws.soap

Examples of org.springframework.ws.soap.SoapMessage


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


    private boolean handleHeaders(EndpointInvocationChain mappedEndpoint,
                                  MessageContext messageContext,
                                  String[] actorsOrRoles,
                                  boolean isUltimateReceiver) {
        SoapMessage soapRequest = (SoapMessage) messageContext.getRequest();
        SoapHeader soapHeader = soapRequest.getSoapHeader();
        if (soapHeader == null) {
            return true;
        }
        Iterator<SoapHeaderElement> headerIterator;
        if (soapHeader instanceof Soap11Header) {
            headerIterator = ((Soap11Header) soapHeader).examineHeaderElementsToProcess(actorsOrRoles);
        }
        else {
            headerIterator =
                    ((Soap12Header) soapHeader).examineHeaderElementsToProcess(actorsOrRoles, isUltimateReceiver);
        }
        List<QName> notUnderstoodHeaderNames = new ArrayList<QName>();
        while (headerIterator.hasNext()) {
            SoapHeaderElement headerElement = headerIterator.next();
            QName headerName = headerElement.getName();
            if (headerElement.getMustUnderstand() && logger.isDebugEnabled()) {
                logger.debug("Handling MustUnderstand header " + headerName);
            }
            if (headerElement.getMustUnderstand() && !headerUnderstood(mappedEndpoint, headerElement)) {
                notUnderstoodHeaderNames.add(headerName);
            }
        }
        if (notUnderstoodHeaderNames.isEmpty()) {
            return true;
        }
        else {
            SoapMessage response = (SoapMessage) messageContext.getResponse();
            createMustUnderstandFault(response, notUnderstoodHeaderNames, actorsOrRoles);
            return false;
        }
    }
View Full Code Here

        template.sendSourceAndReceiveToResult(baseUrl + "/soap/attachment", new StringSource(messagePayload),
                new WebServiceMessageCallback() {

                    @Override
                    public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
                        SoapMessage soapMessage = (SoapMessage) message;
                        final String attachmentContent = "content";
                        soapMessage.addAttachment("attachment-1",
                                new DataHandler(new ByteArrayDataSource(attachmentContent, "text/plain")));
                    }
                }, new StringResult());
    }
View Full Code Here

        transformer = TransformerFactory.newInstance().newTransformer();
    }

    @Test
    public void testHandleInvalidRequestSoap11() throws Exception {
        SoapMessage invalidMessage = soap11Factory.createWebServiceMessage();
        InputStream inputStream = getClass().getResourceAsStream(INVALID_MESSAGE);
        transformer.transform(new StreamSource(inputStream), invalidMessage.getPayloadResult());
        context = new DefaultMessageContext(invalidMessage, soap11Factory);

        boolean result = interceptor.handleRequest(context, null);
        Assert.assertFalse("Invalid response from interceptor", result);
        Assert.assertTrue("Context has no response", context.hasResponse());
        SoapMessage response = (SoapMessage) context.getResponse();
        Assert.assertTrue("Response has no fault", response.getSoapBody().hasFault());
        Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
        Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
                fault.getFaultCode());
        Assert.assertEquals("Invalid fault string on fault", PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON,
                fault.getFaultStringOrReason());
        Assert.assertNotNull("No Detail on fault", fault.getFaultDetail());
View Full Code Here

        Assert.assertNotNull("No Detail on fault", fault.getFaultDetail());
    }

    @Test
    public void testHandleInvalidRequestSoap12() throws Exception {
        SoapMessage invalidMessage = soap12Factory.createWebServiceMessage();
        InputStream inputStream = getClass().getResourceAsStream(INVALID_MESSAGE);
        transformer.transform(new StreamSource(inputStream), invalidMessage.getPayloadResult());
        context = new DefaultMessageContext(invalidMessage, soap12Factory);

        boolean result = interceptor.handleRequest(context, null);
        Assert.assertFalse("Invalid response from interceptor", result);
        Assert.assertTrue("Context has no response", context.hasResponse());
        SoapMessage response = (SoapMessage) context.getResponse();
        Assert.assertTrue("Response has no fault", response.getSoapBody().hasFault());
        Soap12Fault fault = (Soap12Fault) response.getSoapBody().getFault();
        Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_12.getClientOrSenderFaultName(),
                fault.getFaultCode());
        Assert.assertEquals("Invalid fault string on fault", PayloadValidatingInterceptor.DEFAULT_FAULTSTRING_OR_REASON,
                fault.getFaultReasonText(Locale.ENGLISH));
        Assert.assertNotNull("No Detail on fault", fault.getFaultDetail());
View Full Code Here

        Locale locale = new Locale("nl");
        interceptor.setFaultStringOrReason(faultString);
        interceptor.setFaultStringOrReasonLocale(locale);
        interceptor.setAddValidationErrorDetail(false);

        SoapMessage invalidMessage = soap11Factory.createWebServiceMessage();
        InputStream inputStream = getClass().getResourceAsStream(INVALID_MESSAGE);
        transformer.transform(new StreamSource(inputStream), invalidMessage.getPayloadResult());
        context = new DefaultMessageContext(invalidMessage, soap11Factory);

        boolean result = interceptor.handleRequest(context, null);
        Assert.assertFalse("Invalid response from interceptor", result);
        Assert.assertTrue("Context has no response", context.hasResponse());
        SoapMessage response = (SoapMessage) context.getResponse();
        Assert.assertTrue("Response has no fault", response.getSoapBody().hasFault());
        Soap11Fault fault = (Soap11Fault) response.getSoapBody().getFault();
        Assert.assertEquals("Invalid fault code on fault", SoapVersion.SOAP_11.getClientOrSenderFaultName(),
                fault.getFaultCode());
        Assert.assertEquals("Invalid fault string on fault", faultString, fault.getFaultStringOrReason());
        Assert.assertEquals("Invalid fault string locale on fault", locale, fault.getFaultStringLocale());
        Assert.assertNull("Detail on fault", fault.getFaultDetail());
View Full Code Here

            public void fatalError(SAXParseException exception) throws SAXException {
            }
        };
        interceptor.setErrorHandler(errorHandler);
        SoapMessage invalidMessage = soap11Factory.createWebServiceMessage();
        InputStream inputStream = getClass().getResourceAsStream(INVALID_MESSAGE);
        transformer.transform(new StreamSource(inputStream), invalidMessage.getPayloadResult());
        context = new DefaultMessageContext(invalidMessage, soap11Factory);

        boolean result = interceptor.handleRequest(context, null);
        Assert.assertTrue("Invalid response from interceptor", result);
        Assert.assertFalse("Context has response", context.hasResponse());
View Full Code Here

        mapping = (SoapActionAnnotationMethodEndpointMapping) applicationContext.getBean("mapping");
    }

    @Test
    public void registrationSingle() throws Exception {
        SoapMessage requestMock = createMock(SoapMessage.class);
        expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction");
        WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
        replay(requestMock, factoryMock);

        MessageContext context = new DefaultMessageContext(requestMock, factoryMock);
        EndpointInvocationChain chain = mapping.getEndpoint(context);
View Full Code Here

        verify(requestMock, factoryMock);
    }

    @Test
    public void registrationMultiple() throws Exception {
        SoapMessage requestMock = createMock(SoapMessage.class);
        expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction1");
        expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction2");
        WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
        replay(requestMock, factoryMock);

      Method doItMultiple = MyEndpoint.class.getMethod("doItMultiple");
      MethodEndpoint expected = new MethodEndpoint("endpoint", applicationContext, doItMultiple);
View Full Code Here

        verify(requestMock, factoryMock);
    }

    @Test
    public void registrationRepeatable() throws Exception {
        SoapMessage requestMock = createMock(SoapMessage.class);
        expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction3");
        expect(requestMock.getSoapAction()).andReturn("http://springframework.org/spring-ws/SoapAction4");
        WebServiceMessageFactory factoryMock = createMock(WebServiceMessageFactory.class);
        replay(requestMock, factoryMock);

      Method doItRepeatable = MyEndpoint.class.getMethod("doItRepeatable");
      MethodEndpoint expected = new MethodEndpoint("endpoint", applicationContext, doItRepeatable);
View Full Code Here

TOP

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

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.