Ich arbeite mit dem SimpleWebServiceInboundGateway, momentan habe ich das Gateway, das die Anfragen auf einen Kanal stellt, dann einen Fluss, der vom Kanal verbraucht. Alles scheint großartig zu funktionieren.Federintegration SimpleWebServiceInboundGateway
Meine Frage ist, wenn Sie mehrere unterschiedliche Soap-Endpunktdienste haben, die jeweils etwas anders funktionieren, wie mappe ich diese Endpunkte auf verschiedene Flüsse, was ist der richtige Weg, dies zu tun? Wird erwartet, dass Sie einen neuen SimpleWebServiceInboundGateway pro SOAP-Webdienstendpunkt haben und den EndpointMapper verwenden, um jedem einzelnen WebServiceServiceInboundGateway zuzuordnen? Oder gibt es eine bessere Übung dafür? Ich war mir nicht ganz sicher, ob es mehrere Soap Gateways geben sollte.
Auch, eine einfache Möglichkeit, Zugriff auf die URI/URL, die verwendet wurde, um die WS-Aufruf im Fluss zu machen? Ich habe bemerkt, dass es nicht in den Kopfzeilen zu sein scheint.
Hier ist meine Beispielkonfiguration:
/**
* URL mappings used by WS endpoints
*/
public static final String[] WS_URL_MAPPINGS = {"/services/*", "*.wsdl", "*.xsd"};
public static final String GATEWAY_INBOUND_CHANNEL_NAME = "wsGatewayInboundChannel";
public static final String GATEWAY_OUTBOUND_CHANNEL_NAME = "wsGatewayOutboundChannel";
/**
* Register the servlet mapper, note that it uses MessageDispatcher
*/
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
servlet.setTransformSchemaLocations(true);
servlet.setPublishEvents(true);
ServletRegistrationBean servletDef = new ServletRegistrationBean(servlet, WS_URL_MAPPINGS);
servletDef.setLoadOnStartup(1);
return servletDef;
}
/**
* Create a new Direct channels to handle the messages
*/
@Bean
public MessageChannel wsGatewayInboundChannel() {
return MessageChannels.direct(GATEWAY_INBOUND_CHANNEL_NAME).get();
}
@Bean
public MessageChannel wsGatewayOutboundChannel() {
return MessageChannels.direct(GATEWAY_OUTBOUND_CHANNEL_NAME).get();
}
/**
* Startup the WebServiceInboundGateway Endpoint, this will handle the incoming SOAP requests
* and place them onto the request channel
*/
@Bean
public SimpleWebServiceInboundGateway webServiceInboundGateway(
@Value("${spring.ws.should.track:true}") boolean shouldTrack
) {
SimpleWebServiceInboundGateway wsg = new SimpleWebServiceInboundGateway();
wsg.setRequestChannel(wsGatewayInboundChannel());
wsg.setReplyChannel(wsGatewayOutboundChannel());
wsg.setExtractPayload(false); // Send the full RAW SOAPMessage and not just payload
wsg.setLoggingEnabled(true);
wsg.setShouldTrack(shouldTrack);
wsg.setCountsEnabled(true);
return wsg;
}
/**
* Map the allowable service Uri's.
*
* although this isn't needed (can map everything using the mapping.setDefaultEndpoint)
* using this approach ensures that people don't use unexpected uris, probably can
* find a better way to deal with this in the future
*/
@Bean
public EndpointMapping uriEndpointMapping(@Qualifier("serviceUris") List<String> serviceUris
, PayloadValidatingInterceptor payloadValidatingInterceptor
, SimpleWebServiceInboundGateway webServiceInboundGateway) {
UriEndpointMapping mapping = new UriEndpointMapping();
mapping.setUsePath(true);
Map<String, Object> endpointMap = new HashMap<>();
endpointMap.put("/services/myservice1", webServiceInboundGateway);
mapping.setEndpointMap(endpointMap);
//mapping.setDefaultEndpoint(webServiceInboundGateway());
return mapping;
}
@Bean
public IntegrationFlow itemLookupFlow(ItemLookupRequestToItemDetailsRequestTransformer requestTransformer
, ItemDetailsResponseToItemLookupResponseTransformer responseTransformer) {
return IntegrationFlows.from("wsGatewayInboundChannel")
.transform(new MyTransformer())
.log(LoggingHandler.Level.INFO)
.handle(myBean, "execute")
.get();
}
Danke für Ihre Gedanken Artem, ich habe hauptsächlich nur bestätigt, dass es der richtige Weg war. Es scheint begrenzte Beispiele zu geben, also wollte ich sehen, was andere taten. – abe