I am building a simple Spring integration app which reads CSV files from a directory, turns them into XML documents and sends them to a system via a REST XML web service.
The integration flow looks something like this:
<int-file:inbound-channel-adapter channel="filesChannel" ... />
<int:channel id="filesChannel" />
<int:publish-subscribe-channel id="resultChannel" />
<int:chain input-channel="filesChannel" output-channel="resultChannel">
<!-- Parse the CSV into individual messages of Map<String,String> type -->
<int:transformer ref="csvToMapsTransformer" method="transform" />
<int:splitter />
<!-- Transform the map into a simple XML -->
<int:transformer ref="mapToXmlTransformer" method="transform" />
<!-- Use XSLT template to transform the simple XML into the API format -->
<int-xml:xslt-transformer xsl-resource="order-api-transform.xslt" />
<int:header-enricher>
<int:header name="Content-Type" value="text/xml" />
</int:header-enricher>
<!-- Post the XML to the target system -->
<int-http:outbound-gateway
http-method="POST"
url="http://example.com/method"
expected-response-type="javax.xml.transform.Source"
/>
</int:chain>
The mapToXmlTransformer is a simple loop over Map entries which builds an XML string with a StringBuilder. Then this XML string is transformed with XSLT to a format the target system expects.
The flow works pretty much as I am expecting it to. It sends the payload in a POST request to the target system, but it returns an HTTP 415 response:
Caused by: org.springframework.web.client.HttpClientErrorException: 415 Cannot consume content type
It seems like I am doing a simple stupid mistake with my flow, but I am new to Spring Integration and cannot find it myself.
Please help
application/xmlinstead oftext/xmland be very strict about this. Info:application/xmlis also valid and defines media types that are not readable (vague definition) to humans. - meistermeierapplication/xml, but that was not the only problem. A combination of your and Gary's advice helped me! - artemb