0

I need to call a SOAP Webservice from my REST service. I'm using Spring integration in my project. Currently I'm using xml based configuration to achieve the target. But I want to write code in java dsl. Kindly help me how to call a SOAP service from a REST Service using Spring integration DSL.

One example would be really helpful.

1 Answers1

0

See the documentation: https://docs.spring.io/spring-integration/docs/current/reference/html/ws.html#webservices-dsl

@Bean
IntegrationFlow outboundMarshalled() {
    return f -> f.handle(Ws.marshallingOutboundGateway()
                    .id("marshallingGateway")
                    .marshaller(someMarshaller())
                    .unmarshaller(someUnmarshalller()))
        ...
}

or

.handle(Ws.simpleOutboundGateway(template)
            .uri(uri)
            .sourceExtractor(sourceExtractor)
            .encodingMode(DefaultUriBuilderFactory.EncodingMode.NONE)
            .headerMapper(headerMapper)
            .ignoreEmptyResponses(true)
            .requestCallback(requestCallback)
            .uriVariableExpressions(uriVariableExpressions)
            .extractPayload(false))
)
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Hi @Gary Russel, for Ws what is the package? Because I have Spring-integration and dsl dependency added in my project even though I'm not getting Ws. – Somnath Mukherjee Jun 30 '22 at 04:10
  • spring-integration-ws see the start of that chapter https://docs.spring.io/spring-integration/docs/current/reference/html/ws.html#ws you don’t need a separate dependency for the dsl, it has been merged into the core project for a long time now, – Gary Russell Jun 30 '22 at 11:46