@Autowired
private Unmarshaller unmarshaller;
@ServiceActivator
public Message<String> sayHello(Message<String> request) {
WebServiceMessage webServiceRequest;
try {
webServiceRequest = messageFactory.createWebServiceMessage(new ByteArrayInputStream(request.getPayload().getBytes()));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to read SOAP request", e);
}
try {
HelloRequest helloRequest = (HelloRequest) unmarshaller.unmarshal(webServiceRequest.getPayloadSource());
HelloResponse response = new HelloResponse();
response.setMessageId(helloRequest.getMessageId());
response.setCorrelationId(helloRequest.getCorrelationId());
response.setUser("HelloSoapService");
response.setText("Hello " + helloRequest.getUser());
WebServiceMessage webServiceResponse = messageFactory.createWebServiceMessage();
marshaller.marshal(response, webServiceResponse.getPayloadResult());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
webServiceResponse.writeTo(bos);
return MessageBuilder.withPayload(new String(bos.toByteArray())).build();
} catch (XmlMappingException e) {
throw new CitrusRuntimeException("Failed to marshal/unmarshal XML", e);
} catch (IOException e) {