Json ApacheCamel HTTP/HTTP4忽略内容类型头

Json ApacheCamel HTTP/HTTP4忽略内容类型头,json,http-headers,apache-camel,Json,Http Headers,Apache Camel,我正在尝试使用Camel-http通过Apache-Camel发送一个http调用 当我设置标题内容类型时,它会忽略标题,并且不会将其包含在调用中 我已尝试设置标题,如下所示: exchange.getOut().setHeader('Content-Type','application/json'), 及 exchange.getOut().setHeader(exchange.CONTENT_TYPE,'application/json') 我也尝试过使用camel-http和camel-h

我正在尝试使用Camel-http通过Apache-Camel发送一个http调用

当我设置标题内容类型时,它会忽略标题,并且不会将其包含在调用中

我已尝试设置标题,如下所示:

exchange.getOut().setHeader('Content-Type','application/json'),

exchange.getOut().setHeader(exchange.CONTENT_TYPE,'application/json')

我也尝试过使用camel-http和camel-http4,但它们都不起作用

既然我必须强制发送Content-Type头,那么我如何强制Camel-HTTP包含它呢



注意:我还以与呼叫正确发送相同的方式设置了其他标题,这只是内容类型—不起作用的内容类型

您需要执行以下操作来设置内容类型:

<setHeader headerName="Content-Type">

        <constant>application/json</constant>

</setHeader>

应用程序/json

这将用于设置内容类型。

您看过此讨论吗?作为一种解决方法,将正文设置为空json文档,
{}
,camel http自动检测内容类型为application/json并设置正确的内容类型头。这正是我要做的,但是,如果正文为空,则camel http/camel-http4会自动删除内容类型标头。您必须在设置内容类型标头后设置正文。如下所示:
{json text for body here}