Java 如何从blueprint动态设置HTTP方法(驼峰HTTP)
我使用驼峰apache Companient驼峰http。我正在尝试从自定义头设置http方法。我使用蓝图 覆盖过程:Java 如何从blueprint动态设置HTTP方法(驼峰HTTP),java,apache-camel,apache-servicemix,blueprint-osgi,camel-http,Java,Apache Camel,Apache Servicemix,Blueprint Osgi,Camel Http,我使用驼峰apache Companient驼峰http。我正在尝试从自定义头设置http方法。我使用蓝图 覆盖过程: exchange.getOut() 蓝图路线: <route> <from uri="activemq://for_redmine" /> <setHeader headerName="Content-Type"> <constant>application/json
exchange.getOut()代码>
蓝图路线:
<route>
<from uri="activemq://for_redmine" />
<setHeader headerName="Content-Type">
<constant>application/json; charset=utf-8</constant>
</setHeader>
<setHeader headerName="X-Redmine-API-Key">
<constant>beb50ea768f5d16c96030a9dbbf3cb5c4a5ccdcd</constant>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>${header.custom_http_method}</constant>
</setHeader>
<toD uri="${header.url}"/>
</route>
应用程序/json;字符集=utf-8
beb50ea768f5d16c96030a9dbbf3cb5c4a5ccdcd
${header.custom_http_method}
错误:
org.apache.camel.TypeConversionException:从类型java.lang.String转换为所需类型时出错:org.apache.camel.http.common.HttpMethods,值为${header.custom_http_method}due java.lang.IllegalArgumentException:没有枚举常量org.apache.camel.http.common.HttpMethods.${header.custom_http_method}
据我所知,${header.custom_http_method}没有返回值
toD uri=“${header.url}”-工作正常在设置标头CamelHttpMethod时,请尝试使用简单而不是常量
<route>
<from uri="activemq://for_redmine" />
....
<setHeader headerName="CamelHttpMethod">
<simple>${header.custom_http_method}</simple>
</setHeader>
<toD uri="${header.url}"/>
</route>
....
${header.custom_http_method}
在设置标头CamelHttpMethod时,请尝试使用简单而不是常量
<route>
<from uri="activemq://for_redmine" />
....
<setHeader headerName="CamelHttpMethod">
<simple>${header.custom_http_method}</simple>
</setHeader>
<toD uri="${header.url}"/>
</route>
....
${header.custom_http_method}