2013-08-01 11 views
6

Chciałbym zachować oryginalną ładowność oryginalnych żądań i sprawdzić je w transformatorze xslt lub w innej operacji. Tracę go, ponieważ używam transformatora xslt i potrzebuję tylko niektórych elementów transformacji. Tak więc mój scenariusz to:Wiosenna integracja - jak zachować oryginalny ładunek i użyć go później?

1.inbound-gateway (przychodzące WS-req) -> 2.xslt-transformer (mapowanie dla wywołania zewnętrznego WS) -> 3.outbound-gateway (wywołanie zewnętrznego WS) -> 4 .xslt-transformator (tworzenie odpowiedzi od odpowiednich zewnętrznych WS i oryginalnych parametrów)

W czwartym kroku nie mam oryginalnego polecenia, ale potrzebuję go, ponieważ muszę podać wartości z niego do odpowiedzi. Jak mogę to wdrożyć?

Dzięki V.

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-ws="http://www.springframework.org/schema/integration/ws" xmlns:int-xml="http://www.springframework.org/schema/integration/xml" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd      http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> 

<bean id="authenticator" class="uk.co.virginmedia.test.Authenticator"/> 
<bean id="webserviceDestinationProvider" class="uk.co.virginmedia.test.WebserviceDestinationProvider"/> 
<bean id="resultToDocumentTransformer" class="org.springframework.integration.xml.transformer.ResultToDocumentTransformer"/> 

<util:map id="orderNamespaceMap"> 
    <entry key="res" value="http://schema/ReserveAppointment/2/0" /> 
</util:map> 

<int-ws:inbound-gateway id="ws-gateway-for-rbta" request-channel="incoming-req-channel" reply-channel=""/> 

<int:channel id="incoming-req-channel"/> 

<int:service-activator id="authentication" input-channel="incoming-req-channel" ref="authenticator" method="authenticate" output-channel="authenticated-channel" /> 

<int:channel id="authenticated-channel"/> 

<int-xml:xpath-router id="servicetype-router" input-channel="authenticated-channel" evaluate-as-string="true"> 
    <int-xml:xpath-expression expression="//res:ReserveAppointmentRequest/res:serviceType/text()" ns-prefix="res" ns-uri="http://schema/ReserveAppointment/2/0"/> 
    <int-xml:mapping value="Broadband" channel="broadband-channel"/> 
    <int-xml:mapping value="FTTC+WholesaleLineRental" channel="fttc-wlr-channel"/> 
</int-xml:xpath-router> 

<int:channel id="broadband-channel"/> 

<int-xml:xslt-transformer id="req_for_bt_xslt_transformer" input-channel="broadband-channel" output-channel="domresult_for_bt_channel" xsl-resource="classpath:/xsl/ToBTReq.xsl" result-type="StringResult"/> 

<int:channel id="domresult_for_bt_channel"/> 

<int:transformer input-channel="domresult_for_bt_channel" output-channel="document_for_bt_channel" expression="payload.toString()"/> 

<int:channel id="document_for_bt_channel"/> 

<int-ws:outbound-gateway request-channel="document_for_bt_channel" reply-channel="resp_from_bt_channel" destination-provider="webserviceDestinationProvider" id="call_bt-outbound_gateway" /> 

<int:channel id="resp_from_bt_channel"/> 

<int-xml:xslt-transformer id="resp_for_rbta_xslt_transformer" input-channel="resp_from_bt_channel" output-channel="resp_for_rbta_channel" xsl-resource="classpath:/xsl/ToBTReq.xsl" result-type="StringResult"/> 

Odpowiedz

4

Ponieważ oryginalna wiadomość jest tylko tekst można skopiować go do pola nagłówka. Powinno to działać tak długo, jak długo nie będziesz robić nic specjalnego pomiędzy przechowywaniem i późniejszym pobraniem.

Więc co chciałbym spróbować to:

<int:header-enricher input-channel="authenticated-channel" output-channel="pre-routing-channel"> 
    <int:header name="original-payload" expression="payload.toString()" /> 
</int:header-enricher> 

<!-- changed input channel of router --> 
<int-xml:xpath-router id="servicetype-router" input-channel="pre-routing-channel" evaluate-as-string="true"> 

Jeśli to nie działa dla Ciebie (może dlatego, że trzeba zrobić coś bardziej specjalnego pomiędzy czy ładunek jest zbyt duży), nadal mają możliwość korzystać z ClaimCheck. To jest dokładnie to, o co prosisz. W tym celu będziesz potrzebował MessageStore, a następnie zapiszesz ładunek komunikatu, zanim go zmienisz. Więc zamiast nagłówka-enricher zadzwonisz pod numer

<int:claim-check-in input-channel="authenticated-channel" output-channel="pre-routing-channel" message-store="payloadstore" /> 

<!-- MessageStore definition storing payload using in memory map --> 
<bean id="simpleMessageStore" 
    class="org.springframework.integration.store.SimpleMessageStore"/> 
+0

Dzięki, to jest to, czego potrzebuję! – Viktor

Powiązane problemy