2013-08-01 29 views
6

Tôi muốn giữ nguyên tải trọng ban đầu của các yêu cầu ban đầu và đưa nó vào máy biến áp xslt hoặc trong các hoạt động khác. Tôi mất nó bởi vì tôi sử dụng một máy biến áp xslt và tôi chỉ cần một số yếu tố trong quá trình chuyển đổi. Vì vậy, kịch bản của tôi là:Tích hợp mùa xuân - cách giữ trọng tải gốc và sử dụng nó sau này?

1.inbound-gateway (đến WS req) -> 2.xslt-transformer (ánh xạ để gọi WS bên ngoài) -> 3.outbound-gateway (gọi WS bên ngoài) -> 4 .xslt-transformer (tạo phản hồi từ resp. của WS bên ngoài và req gốc)

Ở bước thứ 4 tôi không có req gốc nhưng tôi cần nó vì tôi phải đặt giá trị từ nó để đáp ứng. Làm thế nào tôi có thể thực hiện nó?

Cảm ơn, 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"/> 

Trả lời

4

Kể từ khi thông báo ban đầu của bạn chỉ là văn bản bạn có thể sao chép nó vào một lĩnh vực tiêu đề. Điều này sẽ làm việc miễn là bạn không làm bất cứ điều gì đặc biệt ở giữa khi bạn lưu trữ và sau đó lấy nó.

Vì vậy, những gì tôi sẽ cố gắng là:

<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"> 

Nếu điều này không làm việc cho bạn (có lẽ bởi vì bạn phải làm điều gì đó đặc biệt hơn nữa ở giữa hoặc tải trọng quá lớn), bạn vẫn có tùy chọn để sử dụng một số ClaimCheck. Mà thực sự là chính xác những gì bạn đang yêu cầu. Đối với điều này, bạn sẽ cần một MessageStore và sau đó chỉ cần lưu trữ trọng tải thư trước khi sửa đổi nó. Vì vậy, thay vì tiêu đề-enricher bạn sẽ gọi

<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

Cảm ơn, đây là những gì tôi cần! – Viktor

Các vấn đề liên quan