首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从蓝图动态设置HTTP方法(Camel-http)

如何从蓝图动态设置HTTP方法(Camel-http)
EN

Stack Overflow用户
提问于 2019-02-08 06:53:31
回答 1查看 1.1K关注 0票数 0

我用骆驼-阿帕奇公司的骆驼-http。我正在尝试从我的自定义头设置http方法。我用蓝图

覆盖过程:exchange.getOut().setHeader("custom_http_method", "GET");

蓝图路线:

代码语言:javascript
复制
    <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>

错误: org.apache.camel.TypeConversionException:在类型转换过程中从类型: java.lang.String转换为所需的类型:值为${header.custom_http_method}的org.apache.camel.http.common.HttpMethods : No枚举常量java.lang.IllegalArgumentException

据我所知,$ {header.custom_http_method}没有返回值。

toD uri="${header.url}“-工作正常

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-08 07:08:35

在设置标头时尝试使用简单而不是常量。

代码语言:javascript
复制
 <route>
        <from uri="activemq://for_redmine" />
        ....
         <setHeader headerName="CamelHttpMethod">
          <simple>${header.custom_http_method}</simple> 
         </setHeader> 
        <toD uri="${header.url}"/>
    </route>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54587354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档