Announcement Announcement Module
Collapse
No announcement yet.
How to insert data in xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to insert data in xml

    Hi,
    I am designing one SI project.in the flow there is one field that needed to be hardcoded .Is there way i can insert data in the filed.The file is a type of XML.

    Eg.in the below file i need to insert the country filed from SI flow.I want an alternative to service activator
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
     <person>
               <name>xyz</name>
                <country></country>
      </person>
    Thanks
    Vishal

  • #2
    Vishal

    What you are describing is a classic example of Content Enricher EIP pattern which is realized in Spring Integration via transformer. So it is as simple as implementing a regular transformer which receives XML you described and outputs XML with a new field.

    Comment


    • #3
      Hi oleg,

      My problem here is little bit complicated

      I have an input file to input channel(input) and there is field in the i/p file say country name,but we cannot have it transformed in the transformation but we need that data for the thirdTransformation. is there any way we can store that data in header and retrive it later and add it in xml

      My transformation logic:
      Code:
      <int:transformer id="firstTransformation" input-channel="input" output-channel="output">
       <!--  some transformation  -->
       </int:transformer>
       
        <int:transformer id="secondTransformation" input-channel="output" output-channel="output1">
       <!--  some transformation  -->
       </int:transformer>
       
       <int:transformer id="thirdTransformation" input-channel="output1" output-channel="output2">
       <!--  some transformation  -->
       </int:transformer>
      vishal

      Comment


      • #4
        Yes, its kind of the same thing but you would use Header Enricher component

        Comment


        • #5
          can you please provide a sample snippet.

          Comment


          • #6
            The sample is in the link i included in the previous post:
            Code:
            <int:header-enricher input-channel="in" output-channel="out">
                 <int:header name="foo" value="123"/>
                 <int:header name="bar" ref="someBean"/>
            </int:header-enricher>
            In the above the Message that came in to the 'in' channel will be enriched with two additional headers 'foo' and 'bar' with corresponding values.

            Comment

            Working...
            X