1

I have link

http://www.somelink.com

When I send it with GET Method, I've got XML in view like this

<Value>
  <Id>41</Id>
  <Date>2017-08-16</Date>
  <Role>Customer</Role>
  <Currency>USD</Currency>
  <Counterparties>
    <Counterparty><Id>183</Id>
    <Name>Alex</Name>
    <FullName>dddd</FullName>
    <Contacts>
      <Contact>
        <Type>Mail</Type>
        <Value>email.com</Value>
      </Сontact>
      <Goods>
        <Good>
          <Id>AxojoXSQgN0MZTRX87SJ11</Id>
          <CatalogId>1c_catalog-bd72d8f9-55bc-11d9-848a-00112f43529a</CatalogId>
          <Name>*Good name</Name>
          <Price>340.0000</Price>
          <Quantity>1.0000</Quantity>
          <Sum>340</Sum>
          <Status>[N]New State (И-М)</Status>
          ...
</Value>

So I need transform this xml to object using Spring Integration, but I don't need retrieve all data, just some as Good Name, Counterparty Name and Price with Quantity and transform this into DTO. How to do it best? With JSON it is much easier, but I don't have JSON

1
  • 1
    If you need to transform xml to Pojo, you don't need spring, you can use Jaxb Commented Aug 17, 2017 at 7:56

1 Answer 1

1

I think you still can use <unmarshaller-transformer>, but I'm not sure how it would be possible to avoid nested structure. Although the <int-xml:xpath-transformer> should help you to extract the nested <Good> tag and then send the result to the <unmarshaller-transformer>.

On the other hand you can just use Content Enricher component for simple POJO and call #xpath() SpEL function for properties to extract an appropriate value from that XML.

http://docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/html/messaging-transformation-chapter.html#payload-enricher

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.