Package com.consol.citrus.ws.message

Examples of com.consol.citrus.ws.message.SoapMessage


    @Override
    public void send(Message message, TestContext context) {
        Assert.notNull(message, "Message is empty - unable to send empty message");

        SoapMessage soapMessage;
        if (message instanceof SoapMessage) {
            soapMessage = (SoapMessage) message;
        } else {
            soapMessage = new SoapMessage(message);
        }

        String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(soapMessage);
        context.saveCorrelationKey(correlationKey, this);

        String endpointUri;
        if (getEndpointConfiguration().getEndpointResolver() != null) {
            endpointUri = getEndpointConfiguration().getEndpointResolver().resolveEndpointUri(soapMessage, getEndpointConfiguration().getDefaultUri());
        } else { // use default uri
            endpointUri = getEndpointConfiguration().getDefaultUri();
        }

        log.info("Sending SOAP message to endpoint: '" + endpointUri + "'");

        if (log.isDebugEnabled()) {
            log.debug("Message to send is:\n" + soapMessage.toString());
        }

        if (!(soapMessage.getPayload() instanceof String)) {
            throw new CitrusRuntimeException("Unsupported payload type '" + soapMessage.getPayload().getClass() +
                    "' Currently only 'java.lang.String' is supported as payload type.");
        }

        SoapRequestMessageCallback requestCallback = new SoapRequestMessageCallback(soapMessage, getEndpointConfiguration());
View Full Code Here


        endpoint.setEndpointAdapter(new StaticEndpointAdapter() {
            public Message handleMessageInternal(Message message) {
                Assert.assertTrue(SoapMessage.class.isInstance(message));

                SoapMessage soapMessage = (SoapMessage) message;

                Assert.assertEquals(soapMessage.getAttachments().size(), 1L);

                Attachment attachment = soapMessage.getAttachments().get(0);
                Assert.assertEquals(attachment.getContentId(), "myContentId");
                Assert.assertEquals(attachment.getContentType(), "text/xml");

                Assert.assertEquals(message.getHeader(SoapMessageHeaders.SOAP_ACTION), "sayHello");
View Full Code Here

    @Override
    protected SoapMessage createMessage(TestContext context, String messageType) {
        Message message = super.createMessage(context, getMessageType());

        final SoapMessage soapMessage = new SoapMessage(message);

        try {
            for (SoapAttachment attachment : attachments) {
                if (StringUtils.hasText(attachment.getContent())) {
                    attachment.setContent(context.replaceDynamicContentInString(attachment.getContent()));
                } else if (attachment.getContentResourcePath() != null) {
                    attachment.setContent(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(attachment.getContentResourcePath(), context))));
                }

                soapMessage.addAttachment(attachment);
            }

        } catch (IOException e) {
            throw new CitrusRuntimeException(e);
        }
View Full Code Here

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("soapAttachmentId");
        controlAttachment.setContentType("text/plain");
        controlAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(controlAttachment);

        SimpleSoapAttachmentValidator validator = new SimpleSoapAttachmentValidator();
        validator.validateAttachment(testMessage, Collections.singletonList(controlAttachment));
    }
View Full Code Here

        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentType("text/plain");
        controlAttachment.setContent("This is a test!");
View Full Code Here

        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("wrongAttachmentId");
        controlAttachment.setContentType("text/plain");
View Full Code Here

        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("soapAttachmentId");
        controlAttachment.setContentType("text/plain");
View Full Code Here

        client.getEndpointConfiguration().setWebServiceTemplate(webServiceTemplate);

        MessageCorrelator correlator = EasyMock.createMock(MessageCorrelator.class);
        client.getEndpointConfiguration().setCorrelator(correlator);

        Message requestMessage = new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");

        reset(webServiceTemplate, correlator);

        webServiceTemplate.setDefaultUri("http://localhost:8080/request");
        expectLastCall().once();
View Full Code Here

        SoapAttachment receivedAttachment = new SoapAttachment();
        receivedAttachment.setContentId("soapAttachmentId");
        receivedAttachment.setContentType("text/plain");
        receivedAttachment.setContent("This is a test!");

        SoapMessage testMessage = new SoapMessage("Some Payload")
                                    .addAttachment(receivedAttachment);

        SoapAttachment controlAttachment = new SoapAttachment();
        controlAttachment.setContentId("soapAttachmentId");
        controlAttachment.setContentType("text/xml");
View Full Code Here

        client.getEndpointConfiguration().setWebServiceTemplate(webServiceTemplate);
        EndpointUriResolver endpointUriResolver = EasyMock.createMock(EndpointUriResolver.class);
        client.getEndpointConfiguration().setEndpointResolver(endpointUriResolver);

        Message requestMessage = new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");

        reset(webServiceTemplate, endpointUriResolver);

        webServiceTemplate.setDefaultUri("http://localhost:8080/request");
        expectLastCall().once();
View Full Code Here

TOP

Related Classes of com.consol.citrus.ws.message.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.