Announcement Announcement Module
No announcement yet.
Using int-http:inbound-gateway message-converters verses integrationConversionService Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using int-http:inbound-gateway message-converters verses integrationConversionService

    My question is about the converting messages received at the <int-http:inbound-gateway> using its property message-converters verses using the Spring conversion service and <int:converter>. I have found there are two ways to accomplish conversions, I would like to know which is best for my usage.

    I have set up int-http:inbound-gateway to receive XML sent via HTTP Post of XML. This works fine for XML sent in with HTTP Post and a Content-Type of "text/xml". The datatype on the gateway request-channel is org.w3c.dom.Document, and I had set up a message-convertor to convert the XML String to a Document..

    There is one client does not place the XML in the POST data area, and does not set the Content-Type to "text/xml". Instead they use a HTTP request parameter to send in the XML, and uses the Content-Type of "application/x-www-form-urlencoded". This is in the format of "key = value", where the key is the HTTP parameter name, and the value is the XML (which may be URI encoded).

    I was not able to use a Spring Convertor class from "org.springframework.http.converter" package with this request.

    I was able to read the docs and create a <int:converter>, which can convert a LinkedMultiValueMap to a Document, because the HTTP request parameter is in the key=value format. This convertor is called in SI for every channel which has a Document datatype.

    This convertor does not get called because the use of the gateways convertor list throws an exception and does not even try to call the conversion service. So I now have all messages using the conversion service instead of the gateway message-convertors list.

    Would the conversion service call this convertor just the initial time the message is placed on a channel, or would the convertor class be called multiple times, once for each channel configured with a Document datatype?

    I was thinking using the <int-http:inbound-gateway> "message-converters" property so the conversion is done only once. For the normal HTTP Post this will work, but for the HTTP request parameter message, I have not been able to find a solution. I tried the FormHttpMessageConverter, but it was not able to use the value from the key=value as XML.

    I am starting to try creating a custom class which extends AbstractHttpMessageConverter<Document> to extract the LinkedMultiValueMap XML and convert it to a Document. Do you know of a good example article of how to create a converter class?.