私はSimpleWebServiceInboundGatewayを使って作業していますが、現在はゲートウェイがチャンネルに要求を入れ、次にチャンネルから消費するフローを持っています。すべてがうまくいくようです。spring-integration SimpleWebServiceInboundGateway
私は多少異なる動作をする複数の異なるソープエンドポイントサービスがある場合、これらのエンドポイントを異なるフローにどのようにマッピングすればよいのでしょうか。 SOAPサービスのWebサービスエンドポイントごとに新しいSimpleWebServiceInboundGatewayを用意し、EndpointMapperを使用してそれぞれにマッピングすることが期待されますか?それともこれを行うためのより良い習慣がありますか?私はそれが複数のSoap Gatewaysを持っていると予想されていたかどうかは確かではありませんでした。
また、フローでws呼び出しを行うために使用されたURI/URLへの簡単なアクセス方法はありますか?私はそれがヘッダーにあるように見えないことに気づいた。ここで
は私のサンプルの構成です:
/**
* 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();
}
あなたの考えに感謝Artem、私は主にそれが正しい道であることを確認していました。限られた例があるように私は他人が何をしているのか見たいと思っていました。 – abe